Advertisement
parkdream1

googlefile2.py

May 12th, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.35 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Goofile v1.5
  3. # My Website: http://www.g13net.com
  4. # Project Page: http://code.google.com/p/goofile
  5. #
  6. # TheHarvester used for inspiration
  7. # A many thanks to the Edge-Security team!          
  8. #
  9.  
  10. import string
  11. import httplib
  12. import sys
  13. import re
  14. import getopt
  15.  
  16. print "\n-------------------------------------"
  17. print "|Goofile v1.5                        |"
  18. print "|Coded by Thomas (G13) Richards     |"
  19. print "|www.g13net.com                     |"
  20. print "|code.google.com/p/goofile          |"
  21. print "-------------------------------------\n\n"
  22.  
  23. global result
  24. result =[]
  25.  
  26. def usage():
  27.  print "Goofile 1.5\n"
  28.  print "usage: goofile options \n"
  29.  print "       -d: domain to search\n"
  30.  print "       -f: filetype (ex. pdf)\n"
  31.  print "example:./goofile.py -d test.com -f txt\n"
  32.  sys.exit()
  33.  
  34. def run(dmn,file):
  35.  
  36.     h = httplib.HTTP('www.google.com')
  37.     h.putrequest('GET',"/search?num=500&q=site:"+dmn+"+filetype:"+file)
  38.     h.putheader('Host', 'www.google.com')
  39.     h.putheader('User-agent', 'Internet Explorer 6.0 ')
  40.     h.putheader('Referrer', 'www.g13net.com')
  41.     h.endheaders()
  42.     returncode, returnmsg, headers = h.getreply()
  43.     data=h.getfile().read()
  44.     data=re.sub('<b>','',data)
  45.         for e in ('>','=','<','\\','(',')','"','http',':','//'):
  46.         data = string.replace(data,e,' ')
  47.     r1 = re.compile('[-_.a-zA-Z0-9.-_]*'+'\.'+file)
  48.     res = r1.findall(data)
  49.     return res
  50.    
  51.  
  52. def search(argv):
  53.     global limit
  54.     limit = 100
  55.     if len(sys.argv) < 2:
  56.         usage()
  57.     try :
  58.           opts, args = getopt.getopt(argv,"d:f:")
  59.  
  60.     except getopt.GetoptError:
  61.             usage()
  62.         sys.exit()
  63.    
  64.     for opt,arg in opts :
  65.             if opt == '-f' :
  66.             file=arg
  67.         elif opt == '-d':
  68.             dmn=arg
  69.    
  70.     print "Searching in "+dmn+" for "+ file
  71.     print "========================================"
  72.  
  73.  
  74.     cant = 0
  75.  
  76.     while cant < limit:
  77.         res = run(dmn,file)
  78.         for x in res:
  79.             if result.count(x) == 0:
  80.                     result.append(x)
  81.         cant+=100
  82.            
  83.  
  84.     print "\nFiles found:"
  85.     print "====================\n"
  86.     t=0
  87.     if result==[]:
  88.         print "No results were found"
  89.     else:
  90.         for x in result:
  91.             x= re.sub('<li class="first">','',x)
  92.             x= re.sub('</li>','',x)
  93.             print x
  94.             t+=1
  95.     print "====================\n"
  96.    
  97.  
  98. if __name__ == "__main__":
  99.         try: search(sys.argv[1:])
  100.     except KeyboardInterrupt:
  101.         print "Search interrupted by user.."
  102.     except:
  103.         sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement