-
Notifications
You must be signed in to change notification settings - Fork 2
/
partial_recovery.py
128 lines (104 loc) · 4.42 KB
/
partial_recovery.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import itertools
from mnemonic import Mnemonic
from eth_account import Account
from tqdm import tqdm
from web3 import Web3
def print_logo():
logo = r"""
______ _______ __ __ _______ ________ ______
/ \ / \ / \ / |/ \ / |/ \
/$$$$$$ |$$$$$$$ |$$ \ /$$/ $$$$$$$ |$$$$$$$$//$$$$$$ |
$$ | $$/ $$ |__$$ | $$ \/$$/ $$ |__$$ | $$ | $$ | $$ |
$$ | $$ $$< $$ $$/ $$ $$/ $$ | $$ | $$ |
$$ | __ $$$$$$$ | $$$$/ $$$$$$$/ $$ | $$ | $$ |
$$ \__/ |$$ | $$ | $$ | $$ | $$ | $$ \__$$ |
$$ $$/ $$ | $$ | $$ | $$ | $$ | $$ $$/
$$$$$$/ $$/ $$/ $$/ $$/ $$/ $$$$$$/
______ _______ ________ __ __
/ \ / \ / |/ | / |
/$$$$$$ |$$$$$$$ |$$$$$$$$/ $$ | $$ |
$$ |__$$ |$$ |__$$ |$$ |__ $$ \/$$/
$$ $$ |$$ $$/ $$ | $$ $$<
$$$$$$$$ |$$$$$$$/ $$$$$/ $$$$ \
$$ | $$ |$$ | $$ |_____ $$ /$$ |
$$ | $$ |$$ | $$ |$$ | $$ |
$$/ $$/ $$/ $$$$$$$$/ $$/ $$/
###############################
# #
# CryptoAppex #
# ETH Partial Mnemonic Phrase #
# Recovery Tool #
# V0.1 #
# #
###############################
"""
print(logo)
Account.enable_unaudited_hdwallet_features()
wordlist_file = "wordlist.txt"
def load_wordlist(file_path):
with open(file_path, 'r') as file:
words = file.read().splitlines()
return words
def generate_mnemonic_combinations(partial_mnemonic, wordlist):
slots = partial_mnemonic.count('x')
combinations = itertools.product(wordlist, repeat=slots)
for combo in combinations:
mnemonic = partial_mnemonic
for word in combo:
mnemonic = mnemonic.replace('x', word, 1)
yield mnemonic
def get_eth_address_from_mnemonic(mnemonic):
account = Account.from_mnemonic(mnemonic)
return account.address
def find_correct_mnemonic(partial_mnemonic, target_address, wordlist):
mnemo = Mnemonic("english")
total_combinations = len(wordlist) ** partial_mnemonic.count('x')
with tqdm(total=total_combinations, desc="Processing", unit="mnemonic") as pbar:
for mnemonic in generate_mnemonic_combinations(partial_mnemonic, wordlist):
pbar.update(1)
try:
if not mnemo.check(mnemonic):
continue
if get_eth_address_from_mnemonic(mnemonic) == target_address:
write_result_to_file(mnemonic, target_address)
return mnemonic
except Exception:
continue
return None
def validate_mnemonic(phrase):
words = phrase.split()
return len(words) == 12
def is_valid_ethereum_address(address):
return Web3.is_address(address)
def write_result_to_file(mnemonic, address, filename="Result.txt"):
with open(filename, "w") as file:
file.write("Recovered Mnemonic Phrase:\n")
file.write(f"{mnemonic}\n\n")
file.write("Associated Ethereum Address:\n")
file.write(f"{address}\n")
print(f"Results have been written to {filename}")
def main():
print_logo()
while True:
# Get user inputs
partial_mnemonic = input("What is the mnemonic phrase (put 'x' where you are missing a word)?\n")
# Validate mnemonic
if not validate_mnemonic(partial_mnemonic):
print("Invalid mnemonic phrase. It must be 12 words with 'x' placeholders for missing words.")
continue
target_address = input("What is the target wallet address?\n")
# Validate Ethereum address
if not is_valid_ethereum_address(target_address):
print("Invalid Ethereum address.")
continue
# Load wordlist
wordlist = load_wordlist(wordlist_file)
# Find the correct mnemonic
correct_mnemonic = find_correct_mnemonic(partial_mnemonic, target_address, wordlist)
if correct_mnemonic:
print("Found correct mnemonic:", correct_mnemonic)
else:
print("No matching mnemonic found.")
break
if __name__ == "__main__":
main()