0

This is my first python script (script and programming in general). I have a list of IPs that i would like to run reverse dig on each one. I found the easiest way is to write python script to do just that. The output does not look promising. Can someone please point what i am doing wrong. TIA

from subprocess import call

f_file = open("NET-DNS.txt", "r")

for IP in f_file.readlines():
    call("dig @4.2.2.2 ANY -x " + IP + "+short")

f_file.close()

output:

 ; <<>> DiG 9.12.3 <<>> @4.2.2.2 ANY -x 98.138.219.231
+short
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35543
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 8192
;; QUESTION SECTION:
;231\010+short.219.138.98.in-addr.arpa. IN ANY

;; ANSWER SECTION:
231\010+short.219.138.98.in-addr.arpa. 1560 IN PTR UNKNOWN-98-138-219-X.yahoo.com.

;; AUTHORITY SECTION:
219.138.98.in-addr.arpa. 9832   IN  NS  ns3.yahoo.com.
219.138.98.in-addr.arpa. 9832   IN  NS  ns1.yahoo.com.
219.138.98.in-addr.arpa. 9832   IN  NS  ns5.yahoo.com.
219.138.98.in-addr.arpa. 9832   IN  NS  ns4.yahoo.com.
219.138.98.in-addr.arpa. 9832   IN  NS  ns2.yahoo.com.

;; Query time: 9 msec
;; SERVER: 4.2.2.2#53(4.2.2.2)
;; WHEN: Thu Dec 06 06:01:11 Pacific Standard Time 2018
;; MSG SIZE  rcvd: 197

;; communications error to 4.2.2.2#53: end of file

; <<>> DiG 9.12.3 <<>> @4.2.2.2 ANY -x 98.138.219.231
+short
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1539
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 8192
;; QUESTION SECTION:
;231\010+short.219.138.98.in-addr.arpa. IN ANY

;; ANSWER SECTION:
231\010+short.219.138.98.in-addr.arpa. 1555 IN PTR UNKNOWN-98-138-219-X.yahoo.com.

;; AUTHORITY SECTION:
219.138.98.in-addr.arpa. 9827   IN  NS  ns3.yahoo.com.
219.138.98.in-addr.arpa. 9827   IN  NS  ns1.yahoo.com.
219.138.98.in-addr.arpa. 9827   IN  NS  ns5.yahoo.com.
219.138.98.in-addr.arpa. 9827   IN  NS  ns4.yahoo.com.
219.138.98.in-addr.arpa. 9827   IN  NS  ns2.yahoo.com.

;; Query time: 9 msec
;; SERVER: 4.2.2.2#53(4.2.2.2)
;; WHEN: Thu Dec 06 06:01:16 Pacific Standard Time 2018
;; MSG SIZE  rcvd: 197

;; communications error to 4.2.2.2#53: end of file
;; communications error to 4.2.2.2#53: end of file

Process finished with exit code 0
ciscology
  • 19
  • 2
  • What do you mean by "does not look promising"? – Geno Chen Dec 06 '18 at 14:30
  • I meant to say the output from my script does not look like if you run the command manually. pay attention to how **'+short'** show after the 1st line and in the middle of the out put 'QUESTION & ANSWER SECTION' – ciscology Dec 06 '18 at 18:41
  • 'f_file = open("NET-DNS.txt", "r") for Q in f_file.readlines(): print("This is a test" + Q + "were will this be printed") f_file.close()' output: 'This is a testQuery 1 were will this be printed This is a testQuery 2 were will this be printed This is a testQuery 3 were will this be printed ' – ciscology Dec 06 '18 at 18:50

0 Answers0