Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Created on Oct 20, 2010
- - Gets about 440,000 combinations / sec
- @author: myuser
- '''
- from sys import argv, exit
- from hashlib import *
- def find_hash(wordlist, hash_type, target_hash):
- for line in wordlist:
- if hash_type(line[:-1]).hexdigest() == target_hash: # remove trailing \n
- return line
- return None
- def usage(message=""):
- if message: print message
- print 'Usage: %s [hash_type] [target_hash] [wordlist]' % argv[0]
- print 'hashtype - md5, sha1, sha224, sha256, sha384, sha512'
- exit(1)
- def main():
- if len(argv) != 4:
- usage('Error: Incorrect number of arguments')
- # get correct hash type method from hashlib
- if argv[1] == 'md5' : hash_type = md5
- elif argv[1] == 'sha1' : hash_type = sha1
- elif argv[1] == 'sha224': hash_type = sha224
- elif argv[1] == 'sha256': hash_type = sha256
- elif argv[1] == 'sha384': hash_type = sha384
- elif argv[1] == 'sha512': hash_type = sha512
- else: usage('Error: Unknown hash_type')
- try:
- infile = open(argv[3], 'rU')
- except:
- usage('Unable to open wordlist')
- print 'Attempting to find matching hash', argv[2], 'from', argv[3]
- word = find_hash(infile, hash_type, argv[2])
- if not word:
- print 'Fooey... unable to crack the hash'
- else:
- print 'Found matching hash! Original word:', word
- infile.close()
- if __name__ == '__main__':
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement