Created
September 12, 2015 13:26
-
-
Save dp7k/a03c6a3d8db35a032184 to your computer and use it in GitHub Desktop.
wordlist/dictionary generator for brute-force attacks
This file contains hidden or 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
| #! /usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| import hashlib | |
| import itertools | |
| import string | |
| # generator | |
| def brute_force_generator(chars, max_length): | |
| for length in range(1, max_length+1): | |
| product = itertools.product(chars, repeat=length) | |
| for t in product: | |
| yield ''.join(t) | |
| generator = brute_force_generator(string.ascii_lowercase, 5) | |
| """ # test | |
| l = list(generator) | |
| assert len(l) == 26**1 + 26**2 + 26**3 + 26**4 + 26**5 | |
| assert '' not in l | |
| assert 'x' in l | |
| assert 'foo' in l | |
| assert 'foobar' not in l | |
| print('OK.') | |
| exit() | |
| """ | |
| # example | |
| md5_hash = '21232f297a57a5a743894a0e4a801fc3' | |
| for key in generator: | |
| if hashlib.md5(key.encode('utf-8')).hexdigest() == md5_hash: | |
| print('Key found: %s' % (key)) | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment