Created
March 23, 2015 21:26
-
-
Save wadefletch/03261ff27e4bae6bd304 to your computer and use it in GitHub Desktop.
bruteforce.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import itertools | |
import string | |
import time | |
import console | |
def encrypt(data): | |
return hashlib.md5(data).hexdigest() | |
def crack(hash, charset, maxlength): | |
for attempt in (''.join(candidate) for candidate in itertools.chain.from_iterable(itertools.product(charset, repeat=i) for i in range(1, maxlength + 1))): | |
if encrypt(attempt) == hash: | |
print 'Found:', attempt | |
break | |
if __name__ in '__main__': | |
password = encrypt('WADE') | |
s = time.time() | |
# 62 character charset | |
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' | |
crack(password, alphabet, 4) | |
print 'Finished in', round(s-time.time(), 3)/-1, 'seconds' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment