Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import string
- import hashlib
- import timing
- import json
- import os
- import csv
- value = raw_input("Enter your MD5 hash: ")
- if os.path.isfile("degenerated.txt") == False:
- # Generate lists of character combinations, and then combine them in to one
- # big list to be hashed into hashed_list
- oneChar = map(''.join, itertools.product(string.ascii_lowercase, repeat=1))
- twoChar = map(''.join, itertools.product(string.ascii_lowercase, repeat=2))
- threeChar = map(''.join, itertools.product(string.ascii_lowercase, repeat=3))
- fourChar = map(''.join, itertools.product(string.ascii_lowercase, repeat=4))
- possibleValues = oneChar + twoChar + threeChar + fourChar
- print "List of possible combinations created..."
- json.dump(possibleValues, open("degenerated.txt", 'w'))
- print "... and written to file."
- else:
- print "Values list found, moving on..."
- possibleValues = json.load(open("degenerated.txt"))
- if os.path.isfile("diction.txt") == False:
- hashed_list = (str(hashlib.md5(char).hexdigest()) for char in possibleValues)
- print "Hashed list created..."
- dictToSearch = dict(itertools.izip(hashed_list, possibleValues))
- myfile = open('hashdict.csv', 'wb')
- fieldnames = ('md5', 'value')
- myWriter = csv.DictWriter(myfile, fieldnames=fieldnames)
- headers = dict((n,n) for n in fieldnames)
- myWriter.writerow(headers)
- for n in dictToSearch:
- myWriter.writerow(n)
- myfile.close()
- #json.dump(dictToSearch, open("diction.txt", 'w'))
- print "... and written to file."
- else:
- print "Dictionary found, moving on..."
- dictToSearch = json.load(open("diction.txt"))
- try:
- print "Key = " + dictToSearch[value]
- except KeyError:
- print "Hash unable to be decoded"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement