Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix google search return 301 or 302 bug #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.pyc
8 changes: 4 additions & 4 deletions discovery/googlesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import time

class search_google:
def __init__(self,word,limit,start,filetype):
def __init__(self,word,limit,start,filetype, area):
self.word=word
self.results=""
self.totalresults=""
self.filetype=filetype
self.server="www.google.com"
self.hostname="www.google.com"
self.server="google.com" + "." + area
self.hostname="www.google.com" + "." + area
self.userAgent="(Mozilla/5.0 (Windows; U; Windows NT 6.0;en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
self.quantity="100"
self.limit=limit
self.counter=start

def do_search_files(self):
h = httplib.HTTP(self.server)
h = httplib.HTTPS(self.server)
h.putrequest('GET', "/search?num="+self.quantity+"&start=" + str(self.counter) + "&hl=en&meta=&q=filetype:"+self.filetype+"%20site:" + self.word)
h.putheader('Host', self.hostname)
h.putheader('User-agent', self.userAgent)
Expand Down
10 changes: 7 additions & 3 deletions metagoofil.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def usage():
print " -h: work with documents in directory (use \"yes\" for local analysis)"
print " -n: limit of files to download"
print " -o: working directory (location to save downloaded files)"
print " -f: output file\n"
print " -f: output file"
print " -a: google area(example:hk, default:com)\n"
print " Examples:"
print " metagoofil.py -d apple.com -t doc,pdf -l 200 -n 50 -o applefiles -f results.html"
print " metagoofil.py -h yes -o applefiles -f results.html (local dir analysis)\n"
Expand All @@ -50,10 +51,11 @@ def doprocess(argv):
localanalysis = "no"
failedfiles = []
emails = []
area = "com"
if len(sys.argv) < 3:
usage()
try:
opts, args = getopt.getopt(argv, "l:d:f:h:n:t:o:")
opts, args = getopt.getopt(argv, "l:d:f:h:n:t:o:a:")
except getopt.GetoptError:
usage()
for opt, arg in opts:
Expand All @@ -76,6 +78,8 @@ def doprocess(argv):
dir = arg
elif opt == '-f':
outhtml = arg
elif opt == '-a':
area = arg
if os.path.exists(dir):
pass
else:
Expand All @@ -84,7 +88,7 @@ def doprocess(argv):
print "\n[-] Starting online search..."
for filetype in filetypes:
print "\n[-] Searching for "+ filetype + " files, with a limit of " + str(limit)
search = googlesearch.search_google(word, limit, start, filetype)
search = googlesearch.search_google(word, limit, start, filetype, area)
search.process_files()
files = search.get_files()
print "Results: " + str(len(files)) + " files found"
Expand Down