Thursday, August 19, 2010

hashlib collision generator

To learn how to use hashlib in python, I made a little collision generator for brute forcing password hashes with a dictionary. If you really want a good brute-force tool go download john... but if you're interested in playing with python and hashlib, this was pretty fun.


import hashlib
import sys

dict = open(sys.argv[1], 'r')
hashfile = open(sys.argv[2], 'r')

hashes = hashfile.readlines()

for line in dict:
        h = hashlib.new('md5')
        h.update(line)
        test = h.hexdigest()
        print test
        for i in hashes:
                if i.rstrip() == test:
                        print 'match: ' + test + ' :: ' + line



The script takes two textfiles as arguments, the first being a list of words to use a dictionary, the second being a list of hashes to try to crack.


[root@localhost ~]# python simple_collision.py dict hashes
b1946ac92492d2347c6235b4d2611184
286755fad04869ca523320acce0dc6a4
match: 286755fad04869ca523320acce0dc6a4 :: password

e01096b9ffe3f416157f6ec46c467725
863a872619ff5e00016da42d4c8ea952
5461000db36da004d49fe75f61c77cac
match: 5461000db36da004d49fe75f61c77cac :: lame2

d8e8fca2dc0f896fd7cb4cb0031ba249
df0590f214a2eaf9a638f43838132f67
29f33cab54c2a8858885b95d8fbb7ff1
885474ae15ef15ec2dedd6749d6bc985
4aacf9c858c82716ab0034320bd2efe9
match: 4aacf9c858c82716ab0034320bd2efe9 :: letmein

6ac371cc3dc9d38cf33e5c146617df75

0 comments:

Post a Comment