From 733e3e1cd44a6a3270392c4f6bb981badc7fa467 Mon Sep 17 00:00:00 2001 From: Peter Marsh Date: Fri, 27 Jul 2012 00:46:16 +0100 Subject: [PATCH] Fixed bug where legitmate matches being ignored --- pybozo.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pybozo.py b/pybozo.py index 32b9b4d..f537103 100644 --- a/pybozo.py +++ b/pybozo.py @@ -70,7 +70,7 @@ def webSearch(self, hash): except: pass - + print results return results try: @@ -84,7 +84,7 @@ class MD5Cracker(object): PATTERNS = [ '(?P.+)\s+(?P%s)', '(?P%s):(?P.+)', - '(md5|MD5)\s*\(("|\')?(?P.*?)("|\')?\)\s*(=|:)\s*("|\')?(?P%s)("|\')?', + '(md5|MD5)\s*\(("|\')?(?P.*?)("|\')?\)\s*(=|:)\s*("|\')?(?P%s)("|\')?' ] def __init__(self, patterns = None): @@ -121,9 +121,8 @@ def matches(self, hash, text): for match in matches: plain = match.group('plain') possibleMatches.update([plain, plain.rstrip(), plain.lstrip(), plain.strip()]) - - matches = itertools.ifilter(lambda plain: self.verify(plain, hash), possibleMatches) - + + matches = list(itertools.ifilter(lambda plain: self.verify(plain, hash), possibleMatches)) return matches @@ -213,17 +212,14 @@ def main(hash, cracker, googleAPIKey = None, userAgent = None, **kwargs): google = pygoogle.SearchAPI(key = googleAPIKey) urls = [result.url for result in google.webSearch(str(hash))] - for url in urls: try: text = getText(url, userAgent) matches = cracker.matches(hash, text) - if matches: - for match in matches: - print match + if len(matches): return matches - except urllib2.HTTPError, e: - continue + except: + continue if __name__ == '__main__': @@ -243,5 +239,9 @@ def main(hash, cracker, googleAPIKey = None, userAgent = None, **kwargs): arguments['cracker'] = CRACKERS[arguments['cracker']]() - main(**arguments) + results = main(**arguments) + + if results: + for result in results: + print result