-
Notifications
You must be signed in to change notification settings - Fork 0
/
grin-recover.py
60 lines (51 loc) · 2.39 KB
/
grin-recover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## Author: Anynomous
## Don't forget to install mimlewimble.py: python -m pip install .
import json
import sys
import mimblewimble
from mimblewimble.wallet import Wallet
if __name__ == '__main__':
## TLDR; README
'''
1) Copy the wallet you want to recover the password for into the same directory
as the script. It is assumed your wallet has the name "wallet.seed"
2) Run the script with your passwords list as input, see examples below:
- time cat password_list.txt python.exe grin-recover.py
3) A - Benchmark the speed, measure time it takes to test 10000 passwords single core
- time printf 'HelloWorld\n%.0s' {1..10000} | python grin-recover.py
3) B - Benchmark in parallel, settings are chose for 16 thread Ryzen 7
- time printf 'HelloWorld\n%.0s' {1..100000} | parallel --pipe -j 16 --blocksize 100000 --spreadstdin python grin-recover.py
BENCHMARK RESULTS (Ryzen 7):
- single core 6.693 pwds/second
- 16 thread 40.0000 pwds/second
3) C - Example using hashcat output with multithreading
./hashcat.exe -a1 words.txt endings.txt --stdout | parallel --pipe -j 16 --blocksize 100000 --spreadstdin python grin-recover.py
'''
target_keystore_file = "wallet.seed"
## PASSWORDS are read from standard in (stdin) to allow pyping and multithreading
passwords = sys.stdin.readlines()
## 1) Load the data from the keystore wallet in dictionary
f = open(target_keystore_file)
blob = f.read()
seed = json.loads(blob)
## 2) Loop over all passwords
for pwd in passwords:
password = pwd.strip()
## convert to bytes
encrypted_seed = bytes.fromhex(seed['encrypted_seed'])
nonce = bytes.fromhex(seed['nonce'])
salt = bytes.fromhex(seed['salt'])
## instantiate the wallet
w = Wallet(encrypted_seed=encrypted_seed, nonce=nonce, salt=salt)
## decrypt
valid = True
try:
w.unshieldWallet(password, nonce=nonce, salt=salt)
## If password found, print to stdout/console and to log.txt
if valid:
print('Password found: {}'.format(password))
with open("log.txt", "a") as f:
print("{}:{}".format(target_keystore_file,pwd), file=f)
except Exception as e:
if str(e) == 'MAC check failed':
valid = False