0% found this document useful (0 votes)
257 views

decode.py

The document is a Python script that performs a brute-force attack to decrypt a BIP-38 encrypted Bitcoin private key using a generated passphrase. It checks if the decrypted private key corresponds to a specified target Bitcoin address. The script utilizes libraries for cryptographic functions and includes a delay to manage the brute-force attempts.

Uploaded by

vicky9879871
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
257 views

decode.py

The document is a Python script that performs a brute-force attack to decrypt a BIP-38 encrypted Bitcoin private key using a generated passphrase. It checks if the decrypted private key corresponds to a specified target Bitcoin address. The script utilizes libraries for cryptographic functions and includes a delay to manage the brute-force attempts.

Uploaded by

vicky9879871
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import itertools

import hashlib
import ecdsa
from bip38 import decrypt_bip38_key
from bitcoin import address_from_private_key
import time

# Your BIP-38 encrypted key and confirmation code


encrypted_key = "6PnQmAyBky9ZXJyZBv9QSGRUXkKh9HfnVsZWPn4YtcwoKy5vufUgfA3Ld7" #
Replace with your encrypted key
target_address = "1QGtbKxx6FKDD66LwnrzHCAHmyZ7mDHqC4"

# Helper function to check if the address matches the target


def generate_bitcoin_address_from_private_key(private_key):
private_key_bytes = bytes.fromhex(private_key)
sk = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1)
vk = sk.get_verifying_key()
pubkey = b'\x04' + vk.to_string() # Uncompressed public key
sha256_pubkey = hashlib.sha256(pubkey).digest()
ripemd160_pubkey = hashlib.new('ripemd160', sha256_pubkey).digest()
address = address_from_private_key(private_key)
return address

# Smart passphrase generator (using XXXX-XXXX-XXXX-XXXX-XXXX format)


def generate_passphrase():
charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" # Alphanumeric plus '-'
length = 4 # Length of each segment
for comb in itertools.product(charset, repeat=length):
yield ''.join(comb)

def brute_force_passphrase():
for passphrase in generate_passphrase():
print(f"Trying passphrase: {passphrase}")
decrypted_private_key = decrypt_bip38_key(encrypted_key, passphrase)
if decrypted_private_key:
generated_address =
generate_bitcoin_address_from_private_key(decrypted_private_key)
print(f"Generated Address: {generated_address}")
if generated_address == target_address:
print(f"✅ Found the correct passphrase: {passphrase}")
return passphrase # Return the correct passphrase
else:
print(f"❌ Invalid passphrase: {passphrase}")
time.sleep(0.1) # Small delay to prevent overloading

# Run the brute-force search


if __name__ == "__main__":
brute_force_passphrase()

You might also like