Sunday 11 September 2011

Finding domains on targeted host | Reverse IP lookup



" Reverse IP Lookup " is a very  useful concept for the penetration testers to find out domains which are hosted in targeted host  . Using this concept you can find out the number of domains hosted on a server lets say s4ur4v.com is a server with a server address 1.1.1.1 now when you do a reverse IP lookup on that server you will find the other domains hosted on the same server.

Whats the theory behind this  ?
All web servers are assigned with a unique IP address . If a web server is running a website the IP a address of the site will be same as that of the server. Now if there are multiple domains hosted on the same web server  they will be also having the same IP address of the server . By using this concept " Reverse IP Lookup " we instruct the lookup process to look the number of domains on the target server/host 

How to do a Reverse IP Lookup ? 

Their are a lots of ready made sites which offer you to do a reverse IP look up like yougetsignal

-Go to http://www.yougetsignal.com/
-Gype the server address / website URL
-Click on check and bingo you get the number of domains on the server you looked up


Next i will show you how to do this with a python script which will be using Bing's API to find our dinner ( You can use also DRIL which uses the same )
  1. import httplib, urllib, socket, sys
  2. from xml.dom.minidom import parse, parseString
  3. if len(sys.argv) == 2:
  4.  AppId = '1734E2C92CA63FAA596335295B09CF1D0B5C6161'
  5.  domain = sys.argv[1]
  6.  sites = [domain]
  7.  ip = socket.gethostbyname(domain)
  8.  offset = 50
  9.  while offset < 300:
  10.   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)
  11.   conn = httplib.HTTPConnection("api.bing.net")
  12.   conn.request("GET", uri)
  13.   res = conn.getresponse()
  14.   data = res.read()
  15.   conn.close()
  16.   xmldoc = parseString(data)
  17.   nameEls = xmldoc.getElementsByTagName('web:DisplayUrl')
  18.   for el in nameEls:
  19.    temp = el.childNodes[0].nodeValue
  20.    temp = temp.split("/")[0]
  21.    if temp.find('www.') == -1:
  22.     if temp not in sites:
  23.      sites.append(temp)
  24.   offset += 50
  25.  print "\n\n"
  26.  print "Total: %d domain(s)\n\n"%len(sites)
  27.  for i in sites:
  28.   print i
  29.  print "\n\n"
  30. else:
  31.  print "\n\n\n"
  32.  print "=====================================\n"
  33.  print "Usage: $ python reverse.py domain.com\n"
  34.  print "Ex: $ python reverse.py hackersbay.in   \n"
  35.  print "=====================================\n"
  36.  print "\n\n\n"

Windows users please mind it you have python installed in your OS before running this script.I am going to show it using Backtrack 

- Copy the above script and paste it in a file rename it to reverse.py
- Browse through the directory you saved the file in e.g cd /dir 
- to execute the script you have to just write python reverse.py and then it will show you the how to do the rest :D 

root@bt:~# cd /pentest 

root@bt:/pentest# python reverse.py 

=====================================
Usage: $ python reverse.py domain.com

Ex: $ python reverse.py enhack.net   
=====================================
root@bt:/pentest# python reverse.py davunit8.org

Total: 103 domain(s)

davunit8.org
psplindia.com
jnvkeonjhar.com
microfinanceltd.com
puspitamishra.com
htti-cuttack.com
neemworld.com
keonjhar.net
origininfosystem.com
cippl.com
newditech.com
caravanholidaysindia.com
niateducation.com
sunrayadv.com
spanscaffold.com
suinsys.com
ihmbbs.org
mohindratourist.com
hiem-bdk.org
immunologyofdiabetessociety.com
pipilicrafts.com
dhaneswarinstitutekatak.com
indomer.com
itibalasore.org... continues 

I missed something ? feel free to comment 

No comments:

Post a Comment