inj3ctor_m4

Subdomains Scanner

Oct 3rd, 2014
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. #Subdomains Grabber
  2. #By INJ3CTOR_M4 // facebook.com/H4ck19
  3.  
  4. import re, urllib2, socket, os, sys
  5. from urlparse import urlparse
  6. from platform import system
  7.  
  8. if system() == 'Linux':
  9.     os.system('clear')
  10. if system() == 'Windows':
  11.     os.system('cls')
  12.  
  13. def Bing_sub(domain):
  14.     alldomains = []
  15.     i = 1
  16.     while True:
  17.         bing = urllib2.urlopen('http://www.bing.com/search?q=domain:'+domain+'&first='+str(i)+'&go=&filt=all&FORM=PERE2').read()
  18.         data = re.findall('<h2><a href="(.*?)"', bing)
  19.         for domains in data:
  20.             domains = urlparse(domains)
  21.             alldomains.append(domains.netloc.replace('www.', ''))
  22.         i+=10
  23.         if not re.search('class="sb_pagN"', bing):
  24.             break
  25.     return list(set(alldomains))
  26.  
  27. try:
  28.     domain = sys.argv[1]
  29.     os.unlink('subdomains.txt')
  30.     i = 0
  31.     for b in Bing_sub(domain):
  32.         print (b+' : '+socket.gethostbyname(b))
  33.         subdomains = open('subdomains.txt', 'ab')
  34.         subdomains.write('http://'+b+'\r\n')
  35.         subdomains.close()
  36.         i+=1
  37.     print 'Number of Subdomains : '+str(i)
  38. except IndexError:
  39.     print '\t\tUsage: python '+sys.argv[0]+' [site.com]\n'
Advertisement
Add Comment
Please, Sign In to add comment