Thursday, July 29, 2010

Quick 'n' Dirty Bulk Reverse Lookup

Although you can do bulk forward look-ups using '-f' option in dig, for some reason this does not work for reverse look-ups. See: Dig HowTo

So, I whipped up a quick python script to get the job done. Script assumes you have a file with list of IP's, one per line.
input = open('ips.txt','r')
for i in input.readlines():
   try:
      result = socket.gethostbyaddr(i)
      print i.strip('\n'),result[0]
   except:
      continue
Please use the script at your own risk!

I got the following trick from my good friend Kevin to accomplish similar result using nmap:
nmap -sL -iL fileofips.txt | grep '('

Cheers,
VVK

No comments:

Post a Comment