Friday, August 20, 2010

Reverse IP - The 1st product writen in Python

Base on the idea of this entry posted on 12/31/2009
import httplib, urllib, socket, sys
from xml.dom.minidom import parse, parseString


if len(sys.argv) == 2:
 AppId = '1734E2C92CA63FAA596335295B09CF1D0B5C6161'
 domain = sys.argv[1]
 sites = [domain]
 
 ip = socket.gethostbyname(domain)
 offset = 50
 while offset < 300:
  uri = "/xml.aspx?AppId=%s&Query=ip:%s&Sources=Web&Version=2.0&Market=en-us&Adult=Moderate&Options=EnableHighlighting&Web.Count=50&Web.Offset=%s&Web.Options=DisableQueryAlterations"%(AppId, ip, offset)
 
  conn = httplib.HTTPConnection("api.bing.net")
  conn.request("GET", uri)
  res = conn.getresponse()
  data = res.read()
  conn.close()
  
  
  xmldoc = parseString(data)
  nameEls = xmldoc.getElementsByTagName('web:DisplayUrl')
  for el in nameEls:
   temp = el.childNodes[0].nodeValue
   temp = temp.split("/")[0]
   if temp.find('www.') == -1:
    if temp not in sites:
     sites.append(temp)
  
  offset += 50
 
 print "\n\n"
 print "Total: %d domain(s)\n\n"%len(sites)
 for i in sites:
  print i
 print "\n\n"

else:
 print "\n\n\n"
 print "=====================================\n"
 print "Usage: $ python reverse.py domain.com\n"
 print "Ex: $ python reverse.py enhack.net   \n"
 print "=====================================\n"
 print "\n\n\n"

No comments:

Post a Comment