 |
August 25, 2025, 12:24:07 AM Last edit: August 25, 2025, 12:48:02 AM by junior_clk |
|
I couldn't get anything to work, so I asked chatgpt to make some python files To be clear, I dont have any files, just the 34 character and 16 character I noted as secret key That seemed enough back then (bitcoin 0.3.24 with nodejs or bitcoinj or something, I'm very sure its pre bitcoin 0.4) If I base64 hex the secret key it gives ECA***********CD********* the * is 10 numbers and 9 numbers
# -*- coding: utf-8 -*- import base64 from Crypto.Cipher import AES
BLOCK = 16
def fix_base64(b64): """Voeg ontbrekende = padding toe""" return b64 + "=" * ((4 - len(b64) % 4) % 4)
def decrypt_legacy(secret, b64, debug=True): """AES decryptie zoals BitcoinJ pre-2012""" key = secret # in Python 2, str is al bytes b64_fixed = fix_base64(b64) if debug: print "[DEBUG] Base64 input:", b64 print "[DEBUG] Base64 padded:", b64_fixed
data = base64.b64decode(b64_fixed) if debug: print "[DEBUG] Ciphertext length:", len(data), "bytes" print "[DEBUG] Ciphertext hex:", data.encode('hex'))
for mode in ("ECB", "CBC0"): try: if mode == "ECB": cipher = AES.new(key, AES.MODE_ECB) pt = cipher.decrypt(data) else: iv = "\x00" * BLOCK cipher = AES.new(key, AES.MODE_CBC, iv) pt = cipher.decrypt(data)
if debug: print "[DEBUG] Mode", mode, "decrypted length:", len(pt) print "[DEBUG] Raw plaintext hex:", pt.encode('hex')
pad = ord(pt[-1]) if 1 <= pad <= BLOCK and pt.endswith(chr(pad) * pad): pt = pt[:-pad] if debug: print "[DEBUG] Padding", pad, "removed, new length:", len(pt)
if len(pt) == 32: if debug: print "[SUCCESS] Decrypted private key found!" return pt except Exception as e: if debug: print "[DEBUG] Exception in mode", mode, ":", e) continue return None
if __name__ == "__main__": secret = "7ABCDEFGHIJKLMNO" # jouw 16-char secret encrypted_key = "3CaUUDLAgGNvNL1gh1B*******prWtnuiH" # 34-char string
priv = decrypt_legacy(secret, encrypted_key, debug=True) if priv: print "[RESULT] Private key (hex):", priv.encode('hex') else: print "[RESULT] Kon de sleutel niet ontsleutelen."
and some other, but chatgpt couldnt figure it out, but I know for sure the encrypted key from a few lines above this is correct, the secret key isn't but that shouldn't matter, chatgpt said it doesnt matter if its python 2 or 3 while I read that does matter with the string being for python2 and not 3
|