Spaces:
Runtime error
Runtime error
Commit Β·
9897339
1
Parent(s): f1f9a6c
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,15 @@
|
|
| 1 |
from itertools import permutations, combinations
|
| 2 |
-
import hashlib, hmac, os, time, math,
|
| 3 |
from multiprocessing import Pool
|
| 4 |
from mnemonic import Mnemonic
|
| 5 |
import coincurve
|
| 6 |
from eth_utils import keccak, to_checksum_address
|
| 7 |
|
| 8 |
# ============================================================
|
|
|
|
| 9 |
MY_PHRASE = "lesson cushion crane affair federal decline limb spend reunion chief cart zebra"
|
| 10 |
# ============================================================
|
| 11 |
|
| 12 |
-
_mnemo = Mnemonic("english")
|
| 13 |
-
WORDLIST = _mnemo.wordlist
|
| 14 |
-
NUM_RANDOM_PHRASES = 5
|
| 15 |
-
RANDOM_PHRASES = []
|
| 16 |
-
|
| 17 |
-
my_words = MY_PHRASE.strip().split()
|
| 18 |
-
if len(my_words) == 12:
|
| 19 |
-
RANDOM_PHRASES.append(my_words)
|
| 20 |
-
|
| 21 |
-
for _ in range(NUM_RANDOM_PHRASES):
|
| 22 |
-
RANDOM_PHRASES.append(random.sample(WORDLIST, 12))
|
| 23 |
-
|
| 24 |
# Settings
|
| 25 |
PHRASE_MODE = "replace"
|
| 26 |
BIP39_PASSPHRASE = ""
|
|
@@ -30,7 +19,7 @@ CHECK_BIP39_CHECKSUM = True
|
|
| 30 |
ADDRESSES_FILE = "12730802_addresses.csv"
|
| 31 |
MATCHED_FILE = f"matched_keys_{PHRASE_MODE}.txt"
|
| 32 |
BATCH_SIZE = 5000
|
| 33 |
-
NUM_WORKERS = 16
|
| 34 |
CHUNK_SIZE = 4
|
| 35 |
# ============================================================
|
| 36 |
|
|
@@ -99,7 +88,7 @@ def load_addresses(path):
|
|
| 99 |
a = a[2:]
|
| 100 |
if a and len(a) == 40:
|
| 101 |
s.add(a)
|
| 102 |
-
return s
|
| 103 |
|
| 104 |
def normalize(addr):
|
| 105 |
a = addr.strip().lower()
|
|
@@ -161,14 +150,6 @@ def batch_generator_for_words(wordlist):
|
|
| 161 |
if batch:
|
| 162 |
yield batch
|
| 163 |
|
| 164 |
-
# ---------- Progress bar ----------
|
| 165 |
-
def make_bar(idx, total, tag=""):
|
| 166 |
-
bar_len = 30
|
| 167 |
-
filled = int(bar_len * idx / total)
|
| 168 |
-
bar = "β" * filled + "β" * (bar_len - filled)
|
| 169 |
-
pct = int(100 * idx / total)
|
| 170 |
-
return f" Progress: [{bar}] {idx}/{total} ({pct}%){tag}"
|
| 171 |
-
|
| 172 |
# ---------- Main ----------
|
| 173 |
def main():
|
| 174 |
if not os.path.exists(ADDRESSES_FILE):
|
|
@@ -191,43 +172,40 @@ def main():
|
|
| 191 |
print(f" {'Workers':<22}: {NUM_WORKERS}")
|
| 192 |
print(f" {'Batch Size':<22}: {BATCH_SIZE:,}")
|
| 193 |
print(f" {'Chunk Size':<22}: {CHUNK_SIZE}")
|
| 194 |
-
print(f" {'
|
| 195 |
print(f" {'Output File':<22}: {MATCHED_FILE}")
|
| 196 |
print("=" * 55 + "\n")
|
| 197 |
|
| 198 |
with open(MATCHED_FILE, "w", encoding="utf-8") as f:
|
| 199 |
f.write("")
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
| 204 |
|
| 205 |
-
|
|
|
|
| 206 |
|
| 207 |
with Pool(processes=NUM_WORKERS,
|
| 208 |
initializer=init_worker,
|
| 209 |
initargs=(known,)) as pool:
|
| 210 |
-
|
| 211 |
-
for
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
f.flush()
|
| 226 |
-
os.fsync(f.fileno())
|
| 227 |
-
|
| 228 |
-
all_elapsed = time.time() - all_start
|
| 229 |
-
print(f"\n=== DONE ===")
|
| 230 |
-
print(f"Total time: {all_elapsed/60:.2f} min")
|
| 231 |
print(f"Total matches: {len(total_matches)}")
|
| 232 |
if total_matches:
|
| 233 |
print(f"Results: {MATCHED_FILE}")
|
|
|
|
| 1 |
from itertools import permutations, combinations
|
| 2 |
+
import hashlib, hmac, os, time, math, random
|
| 3 |
from multiprocessing import Pool
|
| 4 |
from mnemonic import Mnemonic
|
| 5 |
import coincurve
|
| 6 |
from eth_utils import keccak, to_checksum_address
|
| 7 |
|
| 8 |
# ============================================================
|
| 9 |
+
# π APNI PHRASE YAHAN DALEIN
|
| 10 |
MY_PHRASE = "lesson cushion crane affair federal decline limb spend reunion chief cart zebra"
|
| 11 |
# ============================================================
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Settings
|
| 14 |
PHRASE_MODE = "replace"
|
| 15 |
BIP39_PASSPHRASE = ""
|
|
|
|
| 19 |
ADDRESSES_FILE = "12730802_addresses.csv"
|
| 20 |
MATCHED_FILE = f"matched_keys_{PHRASE_MODE}.txt"
|
| 21 |
BATCH_SIZE = 5000
|
| 22 |
+
NUM_WORKERS = 16
|
| 23 |
CHUNK_SIZE = 4
|
| 24 |
# ============================================================
|
| 25 |
|
|
|
|
| 88 |
a = a[2:]
|
| 89 |
if a and len(a) == 40:
|
| 90 |
s.add(a)
|
| 91 |
+
return s
|
| 92 |
|
| 93 |
def normalize(addr):
|
| 94 |
a = addr.strip().lower()
|
|
|
|
| 150 |
if batch:
|
| 151 |
yield batch
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
# ---------- Main ----------
|
| 154 |
def main():
|
| 155 |
if not os.path.exists(ADDRESSES_FILE):
|
|
|
|
| 172 |
print(f" {'Workers':<22}: {NUM_WORKERS}")
|
| 173 |
print(f" {'Batch Size':<22}: {BATCH_SIZE:,}")
|
| 174 |
print(f" {'Chunk Size':<22}: {CHUNK_SIZE}")
|
| 175 |
+
print(f" {'Phrase':<22}: {MY_PHRASE}")
|
| 176 |
print(f" {'Output File':<22}: {MATCHED_FILE}")
|
| 177 |
print("=" * 55 + "\n")
|
| 178 |
|
| 179 |
with open(MATCHED_FILE, "w", encoding="utf-8") as f:
|
| 180 |
f.write("")
|
| 181 |
|
| 182 |
+
my_words = MY_PHRASE.strip().split()
|
| 183 |
+
if len(my_words) != 12:
|
| 184 |
+
raise SystemExit(f"Phrase 12 words ki nahi hai ({len(my_words)} words)")
|
| 185 |
+
|
| 186 |
+
print(f" Total combinations: {len(my_words)*len(my_words):,}\n")
|
| 187 |
|
| 188 |
+
total_matches = []
|
| 189 |
+
start = time.time()
|
| 190 |
|
| 191 |
with Pool(processes=NUM_WORKERS,
|
| 192 |
initializer=init_worker,
|
| 193 |
initargs=(known,)) as pool:
|
| 194 |
+
batch_gen = batch_generator_for_words(my_words)
|
| 195 |
+
for hits in pool.imap_unordered(process_batch, batch_gen, chunksize=CHUNK_SIZE):
|
| 196 |
+
for phrase, key_hex, addr in hits:
|
| 197 |
+
print(f"β
MATCH: {phrase}")
|
| 198 |
+
print(f" priv: {key_hex}")
|
| 199 |
+
print(f" addr: {addr}\n")
|
| 200 |
+
total_matches.append((phrase, key_hex, addr))
|
| 201 |
+
with open(MATCHED_FILE, "a", encoding="utf-8") as f:
|
| 202 |
+
f.write(f"{phrase} | {key_hex} | {addr}\n")
|
| 203 |
+
f.flush()
|
| 204 |
+
os.fsync(f.fileno())
|
| 205 |
+
|
| 206 |
+
elapsed = time.time() - start
|
| 207 |
+
print(f"=== DONE ===")
|
| 208 |
+
print(f"Total time: {elapsed:.2f}s")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
print(f"Total matches: {len(total_matches)}")
|
| 210 |
if total_matches:
|
| 211 |
print(f"Results: {MATCHED_FILE}")
|