Sample Header Ad - 728x90

BASH + dig on list of domains gives wrong input to dig with domains suffixed with '\013'

0 votes
0 answers
24 views
I have a list of domains, and I want to use dig to check whether those domains have HTTPS records or not. I ran a for loop to do so, and I realized that the reason why I don't have any result is because the domain name read from the file is suffixed with '\013' string when passed to dig. Hence, I get NXDOMAIN (even for A records which are available for all the domains in my list). My domain list is as follows:
google.com
cloudflare.com
I issue the following loop:
for i in $(cat mydomains.csv); do echo $i; dig  $i; sleep 2; done
In the output, you can see that echo $i shows google.com for the first domain, but in the dig command's output, the requested domain is google.com\013
google.com

; > DiG 9.18.18-0ubuntu0.22.04.1-Ubuntu > google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 30386
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;google.com\013.			IN	A

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Feb 02 15:11:29 +08 2024
;; MSG SIZE  rcvd: 40
I bet this is just some stupid encoding problem, but could not figure out how to overcome this. Anyone had the same issue before?
Asked by cs.lev (101 rep)
Feb 2, 2024, 07:14 AM