Skip to content

Commit

Permalink
Fix Compatability with some really old blockchain.info wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
3rdIteration committed Mar 25, 2024
1 parent d5317d9 commit 1a8765f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions btcrecover/btcrpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,18 +2185,19 @@ def _parse_encrypted_blockchain_wallet(data):
raise ValueError("Can't base64-decode Blockchain wallet: "+str(e))
if len(data) < 32:
raise ValueError("Encrypted Blockchain data is too short")
if len(data) % 16 != 0:
raise ValueError("Encrypted Blockchain data length is not divisible by the encryption blocksize (16)")
#Used to check if the length of the decrypted data was divisible by 16, but this wasn't actually true for all v0 wallets
#if len(data) % 16 != 0:
# raise ValueError("Encrypted Blockchain data length is not divisible by the encryption blocksize (16)")

# If this is (possibly) a v0.0 (a.k.a. v1) wallet file, check that the encrypted data
# looks random, otherwise this could be some other type of base64-encoded file such
# as a MultiBit key file (it should be safe to skip this test for v2.0+ wallets)
if not iter_count: # if this is a v0.0 wallet
# The likelihood of of finding a valid encrypted blockchain wallet (even at its minimum length
# of about 500 bytes) with less than 7.4 bits of entropy per byte is less than 1 in 10^6
# (decreased test below to 7.1 after being shown a wallet with 7.1 entropy bits)
# (decreased test below to 7.0 after being shown a wallet with 7.0 entropy bits)
entropy_bits = est_entropy_bits(data)
if entropy_bits < 7.1:
if entropy_bits < 7.0:
raise ValueError("Doesn't look random enough to be an encrypted Blockchain wallet (only {:.1f} bits of entropy per byte)".format(entropy_bits))

return data, iter_count # iter_count == 0 for v0 wallets
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tex1TnplnL/WmUoNRYDBDdwfK9g7WwBqixcqu8PwSh6G9wRqHfLQ9yWQ6+aDmqSfwVlJvkTrQPwdfOhtDl9hctGffmlclGOeJs/G+QmnbGosgTViqQs/LLOroSm658w/PaQx5Eo/AQ5LSj42X+HcCzGWjNHf6tJM92WO68tWq0gzc/cRDS4yO6t+Rj2Fnm+AiAtrkGi7DHjKlCdDUMqdzF5MsPfJ6TdRoz4xDVHrDoNkDHQVn8I5xRC8YMGCL4TjsLK8idN/gTIous2yiVlkTG3Jf5a97VZEUgYLsd9HHarInDLl5n1i1QP7/ATz3ViAVegZx8/J
4 changes: 4 additions & 0 deletions btcrecover/test/test_passwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,10 @@ def test_blockchain_github_v1_3_secondpass(self):
def test_blockchain_v0_Jan2014(self):
self.wallet_tester("blockchain-v0.0-Jan2014-wallet.aes.json", correct_pass="testblockchain")

@skipUnless(can_load_pycrypto, "requires PyCryptoDome")
def test_blockchain_v0_Mar2012_uncompressed(self):
self.wallet_tester("blockchain-v0.0-march2012-uncompressed-wallet.aes.json", correct_pass="inmydreams")

@skipUnless(can_load_pycrypto, "requires PyCryptoDome")
def test_blockchain_v3_Jan2021(self):
self.wallet_tester("blockchain-v3.0-Jan2021-Android.json", correct_pass="Testing123!")
Expand Down

0 comments on commit 1a8765f

Please sign in to comment.