Created
December 25, 2017 11:08
-
-
Save chebykin/c0c0a36d8eda558f375a120106d888c0 to your computer and use it in GitHub Desktop.
Recover Ethereum Password For Key JSON File (Python 3)
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
from ethereum.tools.keys import decode_keystore_json #keys.py from pyethereum, we only want the decode_keystore_json function | |
import json | |
import itertools | |
import sys | |
import traceback | |
from joblib import Parallel, delayed | |
print(sys.version) | |
class PasswordFoundException(Exception): | |
pass | |
combinations=[ | |
] | |
def generate_all(el, tr): #taken from pyethrecover | |
if el: | |
for j in range(len(el[0])): | |
for w in generate_all(el[1:], tr + el[0][j]): | |
yield w | |
else: | |
yield tr | |
def attempt(w, pw): | |
#raise PasswordFoundException("Trying %s" % pw) | |
if len(pw) < 22: | |
return "" | |
try: | |
o = decode_keystore_json(w,pw) | |
print("Password found") | |
print(o) | |
# WARNING password output isn't correct now, has to be fixed | |
raise PasswordFoundException("""\n\nYour password is:\n%s""" % o) | |
except ValueError as e: | |
# print(e) | |
return "" | |
def tryopen(f): | |
try: | |
assert f | |
t = open(f).read() | |
try: | |
return json.loads(t) | |
except: | |
raise Exception("Corrupted file: "+f) | |
except: | |
return None | |
def __main__(): | |
w = tryopen("wallet.json") | |
pwds=[] | |
print("Total passes to check: %d" % len(list(generate_all(combinations,'')))) | |
pwds = itertools.chain(pwds, generate_all(combinations,'')) | |
try: | |
Parallel(n_jobs=-1)(delayed(attempt)(w, pw) for pw in pwds) | |
# print("\n") | |
except Exception as e: | |
#traceback.print_exc() | |
while True: | |
sys.stdout.write('\a') | |
sys.stdout.flush() | |
if __name__ == "__main__": | |
__main__() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment