Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. '''
  2. Created on Oct 20, 2010
  3. - Gets about 440,000 combinations / sec
  4.  
  5. @author: myuser
  6. '''
  7. from sys import argv, exit
  8. from hashlib import *
  9.  
  10. def find_hash(wordlist, hash_type, target_hash):
  11.     for line in wordlist:
  12.         if hash_type(line[:-1]).hexdigest() == target_hash: # remove trailing \n
  13.             return line
  14.     return None
  15.  
  16. def usage(message=""):
  17.     if message: print message
  18.     print 'Usage: %s [hash_type] [target_hash] [wordlist]' % argv[0]
  19.     print 'hashtype  -  md5, sha1, sha224, sha256, sha384, sha512'
  20.     exit(1)
  21.  
  22. def main():
  23.     if len(argv) != 4:
  24.         usage('Error: Incorrect number of arguments')
  25.    
  26.     # get correct hash type method from hashlib
  27.     if   argv[1] == 'md5'   : hash_type = md5
  28.     elif argv[1] == 'sha1'  : hash_type = sha1
  29.     elif argv[1] == 'sha224': hash_type = sha224
  30.     elif argv[1] == 'sha256': hash_type = sha256
  31.     elif argv[1] == 'sha384': hash_type = sha384
  32.     elif argv[1] == 'sha512': hash_type = sha512
  33.     else: usage('Error: Unknown hash_type')
  34.    
  35.     try:
  36.         infile = open(argv[3], 'rU')
  37.     except:
  38.         usage('Unable to open wordlist')
  39.    
  40.     print 'Attempting to find matching hash', argv[2], 'from', argv[3]
  41.     word = find_hash(infile, hash_type, argv[2])
  42.    
  43.     if not word:
  44.         print 'Fooey... unable to crack the hash'
  45.     else:
  46.         print 'Found matching hash! Original word:', word
  47.     infile.close()
  48.    
  49. if __name__ == '__main__':
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement