Created
November 20, 2014 05:53
-
-
Save ryancdotorg/4c2a8d2fe96052f24dd0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import sys | |
from binascii import hexlify | |
from pybitcointools import * | |
from joblib import Parallel, delayed | |
import multiprocessing | |
num_cores = multiprocessing.cpu_count() | |
addrs = set() | |
with open('addrs') as f: | |
for line in f: | |
addrs.add(line.strip()) | |
def trykey(key): | |
try: | |
priv_u = encode_privkey(key, 'hex') | |
priv_c = encode_privkey(key, 'hex_compressed') | |
wif_u = encode_privkey(priv_u, 'wif', 52) | |
wif_c = encode_privkey(priv_c, 'wif_compressed', 52) | |
pub_u = encode_pubkey(privtopub(priv_u), 'hex') | |
pub_c = encode_pubkey(pub_u, 'hex_compressed') | |
addr_u = pubtoaddr(pub_u, 52) | |
addr_c = pubtoaddr(pub_c, 52) | |
if addr_u in addrs: | |
addrs.remove(addr_u) | |
print "FOUND %s %s uncompressed" % (addr_u, wif_u) | |
if addr_c in addrs: | |
addrs.remove(addr_c) | |
print "FOUND %s %s compressed" % (addr_c, wif_c) | |
except: | |
if len(key) < 64: | |
key = hexlify(key) | |
print "failed to process " + key | |
try: | |
keys = set() | |
with open('keys') as f: | |
for line in f: | |
keys.add(line.strip()) | |
print "fast scan..." | |
for key in keys: | |
trykey(key) | |
except: | |
print "keys file not found" | |
print "deep scan..." | |
wh = open('wallet.dat', 'rb') | |
w = wh.read() | |
deep_keys = set() | |
for offset in xrange(len(w)-32): | |
end = offset + 32 | |
key = w[offset:end] | |
deep_keys.add(key) | |
print "got %d candidate keys" % len(deep_keys) | |
Parallel(n_jobs=num_cores)( | |
delayed(trykey)(key) for key in deep_keys | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment