[GH-ISSUE #2654] Electrum format fails to load large (huge) hashes #1722

Closed
opened 2026-10-15 04:23:22 +07:00 by bsakaguchi · 9 comments
Owner

Originally created by @t4777sd on GitHub (Aug 5, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2654

Originally assigned to: @kholia on GitHub.

Steps to reproduce

I am testing the latest feature for electrum wallets. This appears to create a password hash line that contains the entire wallet file as part of the password hash line. Since wallet files can be quite large, it makes it so john will not load the hash.

I suspect there is some upper limit to the size of hashes and any hash over a certain length is ignored. I tested in on my wallet file which produces a password hash line that is 350KB and it fails to load the hash ("No password hashes loaded "). I tested it on a newly created wallet file which which created an 11KB password hash line and it worked.

System configuration

/opt/John/john --list=build-info
Version: 1.8.0-jumbo-1-5774-g8d7ccaf
Build: linux-gnu 64-bit AVX2-ac MPI + OMP
SIMD: AVX2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1
$JOHN is /opt/John/
Format interface version: 14
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
gcc version: 5.4.0
GNU libc version: 2.23 (loaded: 2.23)
Crypto library: OpenSSL
OpenSSL library version: 01000207f
OpenSSL 1.0.2g 1 Mar 2016
GMP library version: 6.1.0
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's

Originally created by @t4777sd on GitHub (Aug 5, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2654 Originally assigned to: @kholia on GitHub. ### Steps to reproduce I am testing the latest feature for electrum wallets. This appears to create a password hash line that contains the **entire wallet file as part of the password hash line**. Since wallet files can be quite large, it makes it so john will not load the hash. I suspect there is some upper limit to the size of hashes and any hash over a certain length is ignored. I tested in on my wallet file which produces a password hash line that is 350KB and it fails to load the hash ("No password hashes loaded "). I tested it on a newly created wallet file which which created an 11KB password hash line and it worked. ### System configuration /opt/John/john --list=build-info Version: 1.8.0-jumbo-1-5774-g8d7ccaf Build: linux-gnu 64-bit AVX2-ac MPI + OMP SIMD: AVX2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1 $JOHN is /opt/John/ Format interface version: 14 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 gcc version: 5.4.0 GNU libc version: 2.23 (loaded: 2.23) Crypto library: OpenSSL OpenSSL library version: 01000207f OpenSSL 1.0.2g 1 Mar 2016 GMP library version: 6.1.0 File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's
bsakaguchi 2026-10-15 04:23:22 +07:00
Author
Owner

@kholia commented on GitHub (Aug 6, 2017):

Currently, there is a limit of around 16 KB on the electrum hash size.

Can you post the steps you took to generate the 350 KB hash? How can I reproduce this problem locally? Which version of Electrum Bitcoin Wallet are you using?

I think https://github.com/gurnec/btcrecover will work better for such huge wallets.

Update:

I think that your wallet might be using the new Electrum 2.8+ encrypted format. In such cases, including almost all the wallet data in the hash is necessary with our current cracking method.

<!-- gh-comment-id:320505696 --> @kholia commented on GitHub (Aug 6, 2017): Currently, there is a limit of around 16 KB on the electrum hash size. Can you post the steps you took to generate the 350 KB hash? How can I reproduce this problem locally? Which version of Electrum Bitcoin Wallet are you using? I think https://github.com/gurnec/btcrecover will work better for such huge wallets. Update: I think that your wallet might be using the new Electrum 2.8+ encrypted format. In such cases, including almost all the wallet data in the hash is necessary with our current cracking method.
Author
Owner

@kholia commented on GitHub (Aug 6, 2017):

After looking at btcrecover, it seems that we could support such huge hashes in JtR but at the cost of generating false positives. I haven't experimented with this idea yet, so I don't know if the rate of false positives is reasonable.

<!-- gh-comment-id:320507581 --> @kholia commented on GitHub (Aug 6, 2017): After looking at `btcrecover`, it seems that we could support such huge hashes in JtR but at the cost of generating false positives. I haven't experimented with this idea yet, so I don't know if the rate of false positives is reasonable.
Author
Owner

@t4777sd commented on GitHub (Aug 7, 2017):

Yes, I am using the new wallet format. Unfortunately, I am using keepass and I created an 8 char password to set the password and I closed keepass without saving the new password, so the password was lost once it left my clipboard. I tried btcrecover, but since it is a random 8 char password it is almost impossible due to memory usage of btcrecover and how slow it is.

If JtR could support the large hashes that electrum requires or another solution, then it would be great. False positives are better than nothing, in my case.

<!-- gh-comment-id:320754950 --> @t4777sd commented on GitHub (Aug 7, 2017): Yes, I am using the new wallet format. Unfortunately, I am using keepass and I created an 8 char password to set the password and I closed keepass without saving the new password, so the password was lost once it left my clipboard. I tried btcrecover, but since it is a random 8 char password it is almost impossible due to memory usage of btcrecover and how slow it is. If JtR could support the large hashes that electrum requires or another solution, then it would be great. False positives are better than nothing, in my case.
Author
Owner

@kholia commented on GitHub (Aug 8, 2017):

I am not confident about recovering a random password of length 8 in a reasonable amount of time (e.g. three months).

With our current OpenCL code,

$ ../run/john --test --format=electrum-modern-opencl
Will run 32 OpenMP threads
Device 6: GeForce GTX TITAN X
Benchmarking: electrum-modern-opencl, Electrum Wallet 2.8+ [SHA256 AES 32/64]...
Raw:	48188 c/s real, 2572 c/s virtual

I think that the corresponding CPU format would be too slow to attack this problem.

@gurnec You might be interested in this topic I think, thanks!

<!-- gh-comment-id:320842442 --> @kholia commented on GitHub (Aug 8, 2017): I am not confident about recovering a random password of length 8 in a reasonable amount of time (e.g. three months). With our current OpenCL code, ``` $ ../run/john --test --format=electrum-modern-opencl Will run 32 OpenMP threads Device 6: GeForce GTX TITAN X Benchmarking: electrum-modern-opencl, Electrum Wallet 2.8+ [SHA256 AES 32/64]... Raw: 48188 c/s real, 2572 c/s virtual ``` I think that the corresponding CPU format would be too slow to attack this problem. @gurnec You might be interested in this topic I think, thanks!
Author
Owner

@gurnec commented on GitHub (Aug 9, 2017):

From a feasibility point of view, I agree with @kholia - an Electrum 2.8 fully-encrypted wallet with an 8 char alphanumeric password would take on the order of years or tens of years to crack, even on fairly big iron.

After looking at btcrecover, it seems that we could support such huge hashes in JtR but at the cost of generating false positives.

btcrecover checks the full MAC, just like JtR, so I wouldn't expect any false positives.

But back on topic: if you look at these five bullet points, btcrecover uses the first, second, and last (the first and second just weed out some true negatives, the last is the full MAC check), and JtR currently uses the last.

The third bullet point is the thought I had for JtR if the lines in the hashes file had limited length and couldn't store the entire file. I created a Python proof of concept here to try this out (it tries bullet points one and three, and seems to work).

One problem is that it's difficult to reason about the false positive rate (I'm pretty sure there are no false negatives). It should at least as good as 1 in 251, possibly much lower with that final regex check, but with the zlib stuff in the way, it's hard for me to tell.

Of course since this particular wallet seems infeasible, I'm not sure how important implementing this in JtR would be....

<!-- gh-comment-id:321399145 --> @gurnec commented on GitHub (Aug 9, 2017): From a feasibility point of view, I agree with @kholia - an Electrum 2.8 fully-encrypted wallet with an 8 char alphanumeric password would take on the order of years or tens of years to crack, even on fairly big iron. > After looking at btcrecover, it seems that we could support such huge hashes in JtR but at the cost of generating false positives. btcrecover checks the full MAC, just like JtR, so I wouldn't expect any false positives. But back on topic: if you look at these [five bullet points](https://github.com/magnumripper/JohnTheRipper/issues/2504#issuecomment-309228768), btcrecover uses the first, second, and last (the first and second just weed out some true negatives, the last is the full MAC check), and JtR currently uses the last. The third bullet point is the thought I had for JtR if the lines in the hashes file had limited length and couldn't store the entire file. I created a Python [proof of concept here](https://gist.github.com/gurnec/66eb171edff734a6fb30c7b216137b4c) to try this out (it tries bullet points one and three, and seems to work). One problem is that it's difficult to reason about the false positive rate (I'm pretty sure there are no false negatives). It should at least as good as 1 in 2<sup>51</sup>, possibly much lower with that final [regex check](https://gist.github.com/gurnec/66eb171edff734a6fb30c7b216137b4c#file-electrum28-test-py-L12-L14), but with the zlib stuff in the way, it's hard for me to tell. Of course since this particular wallet seems infeasible, I'm not sure how important implementing this in JtR would be....
Author
Owner

@kholia commented on GitHub (Aug 10, 2017):

Thanks @gurnec.

I was planning on using only the first, and second checks for such large hashes. I think doing so will result in false positives.

The third check is very interesting! I will experiment with it to see if we can put a reasonable upper limit on the number of blocks to decrypt and decompress.

Thanks for the great ideas 👍

<!-- gh-comment-id:321458840 --> @kholia commented on GitHub (Aug 10, 2017): Thanks @gurnec. I was planning on using only the first, and second checks for such large hashes. I think doing so will result in false positives. The third check is very interesting! I will experiment with it to see if we can put a reasonable upper limit on the number of blocks to decrypt and decompress. Thanks for the great ideas 👍
Author
Owner

@gurnec commented on GitHub (Aug 10, 2017):

I was planning on using only the first, and second checks for such large hashes. I think doing so will result in false positives.

It definitely will, those two only "pin" 19 + 8 bits respectively, so that's a false positive rate as high as 1 in 227.

a reasonable upper limit on the number of blocks to decrypt and decompress

I went with 512 bytes as the comment said. Also just FYI, the test wallet I used (which is an empty wallet) only needed 80 bytes before it could be identified.

<!-- gh-comment-id:321671017 --> @gurnec commented on GitHub (Aug 10, 2017): > I was planning on using only the first, and second checks for such large hashes. I think doing so will result in false positives. It definitely will, those two only "pin" 19 + 8 bits respectively, so that's a false positive rate as high as 1 in 2<sup>27</sup>. > a reasonable upper limit on the number of blocks to decrypt and decompress I went with 512 bytes as the comment said. Also just FYI, the test wallet I used (which is an empty wallet) only needed 80 bytes before it could be identified.
Author
Owner

@t4777sd commented on GitHub (Aug 14, 2017):

Awesome, I hope that a solution makes it into JtR so I can try it. In my case, the password is all lowercase, so it will likely be recoverable if it can work in JtR. Even if it takes me 2 years to do it then it will be worth it considering the amount of coins I have lost in the wallet.

So I pray that this gets added to JtR.

<!-- gh-comment-id:322257968 --> @t4777sd commented on GitHub (Aug 14, 2017): Awesome, I hope that a solution makes it into JtR so I can try it. In my case, the password is all lowercase, so it will likely be recoverable if it can work in JtR. Even if it takes me 2 years to do it then it will be worth it considering the amount of coins I have lost in the wallet. So I pray that this gets added to JtR.
Author
Owner

@kholia commented on GitHub (Aug 16, 2017):

This issue should be fixed now.

However, I am not confident that the new code is 100% correct and will work for all cases. It does work for the sample data we have but there are no further guarantees.

<!-- gh-comment-id:322738017 --> @kholia commented on GitHub (Aug 16, 2017): This issue should be fixed now. However, I am not confident that the new code is 100% correct and will work for all cases. It does work for the sample data we have but there are no further guarantees.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1722
No description provided.