Skip to content

Instantly share code, notes, and snippets.

@achow101 achow101/ Secret
Created Feb 20, 2018

What would you like to do?
import binascii
import os
import array
header = [0xd6,0x30,0x81,0xD3,0x02,0x01,0x01,0x04,0x20]
header_ptr = 0
privkeys = []
with open("/home/andy/.bitcoin/regtest/wallets/unencrypted_7_orig", "rb") as f:
read_bytes =
in_privkey = False
cur_privkey = []
print("Reading 1024 bytes at a time")
for b in read_bytes:
if in_privkey and len(cur_privkey) < 32:
elif len(cur_privkey) == 32:
pk = array.array('B', cur_privkey).tostring()
print("Found a private key " + str(len(privkeys)))
in_privkey = False
if b == header[header_ptr]:
header_ptr += 1
if header_ptr == len(header):
# We're now at a private key
in_privkey = True
header_ptr = 0
header_ptr = 0
print("Checking log files now")
privkey_found = False
for filename in os.listdir("/home/andy/.bitcoin/regtest/wallets/database"):
with open("/home/andy/.bitcoin/regtest/wallets/database/" + filename, "rb") as f:
read_bytes =
for privkey in privkeys:
if privkey in read_bytes:
privkey_found = True
print("Private key in bytes " + str(binascii.hexlify(privkey)))
if not privkey_found:
print("No Privkeys found")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.