r/ScriptSwap • • Mar 06 '12

[Python] Salted MD5 dictionary brute force

import sys,hashlib
hash = str(sys.argv[1])
salt = str(sys.argv[2])
dict = str(sys.argv[3])
with open(dict) as f:
    l = f.readlines()
    for line in f:
            hsh = hashlib.md5(line.replace('\n','') +salt).hexdigest()
            if hsh == hash:
                    print '\n Found Password: '+ line + '\n'
                    f.close()
                    sys.exit(1)

Usage: brute.py <hash to bruteforce> <salt> <dictionary>

Note to everyone: If you have any optimizations, feel free to write them in the comments!

8 Upvotes

3 comments sorted by

View all comments

Show parent comment

2

u/WendellJehangir Mar 06 '12

It runs pretty well, currently it will run better now that I've gotten rid of the lines telling it to write to stdout every time it gets one wrong. It's computing a hash for each word in your dictionary, so it runs decently, depending on the size of your dictionary. It's been successful with my usage of it.