[GH-ISSUE #2725] Improve JKS cracking support in JtR #1753

Open
opened 2026-10-15 04:24:04 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @kholia on GitHub (Sep 4, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2725

Originally assigned to: @kholia on GitHub.

References,

I haven't checked if this can be done in JtR land.

Originally created by @kholia on GitHub (Sep 4, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2725 Originally assigned to: @kholia on GitHub. References, * https://github.com/floyd-fuh/JKS-private-key-cracker-hashcat * https://unpack.debug.su/pocorgtfo/pocorgtfo15.pdf ("15:12 Nail in the Java Key Store Coffin") I haven't checked if this can be done in JtR land.
Author
Owner

@kholia commented on GitHub (Nov 3, 2017):

I don't see how the technique presented in this article drastically improves the cracking speed. I will implement it sometime though, to be 100% sure. Currently, I am not convinced about many of the performance claims present in this article.

The bits about having the ability to crack the private key password(s) in addtion to the keystore password are obviously correct.

<!-- gh-comment-id:341648451 --> @kholia commented on GitHub (Nov 3, 2017): I don't see how the technique presented in this article drastically improves the cracking speed. I will implement it sometime though, to be 100% sure. Currently, I am not convinced about many of the performance claims present in this article. The bits about having the ability to crack the private key password(s) *in addtion* to the keystore password are obviously correct.
Author
Owner

@floyd-fuh commented on GitHub (Aug 13, 2020):

@kholia author of those things here, happy to discuss why you think the cracking speed wouldn't be a lot faster. Instead of putting in the password, "Mighty Aphrodite" and the entire key store file (except the checksum itself, but the file could include hundreds of keys, but of course it depends) in the SHA-1 calculation you only put in the password plus 20 bytes IV. And of course hashing a lot less bytes is faster than hashing a lot more bytes. Another way to look at it is that simply my simple python script was cracking faster than John.

Don't crack the keystore password. It is useless. It is only useful if you know it is reused (which you don't know for JKS itself because it's just the default). And even then, the other method is faster. Or even worse: you could be cracking a JKS keystore password, just to never realize that there is no private key in it and you could have extracted all the content without the password (public keys are not encrypted).

If john jumbo wants to crack JKS private keys as efficiently as hashcat, you will probably need to replace keystore2john.py with https://github.com/floyd-fuh/JKS-private-key-cracker-hashcat/blob/master/JksPrivkPrepare/JksPrivkPrepare.java and then do a rewrite of the keystore module.

If you want me to print the things in JKS-private-key-cracker-hashcat in John format, let me know and I should be able to add a command line switch that outputs john format, I just need to know the format. The keystore cracking module rewrite would need to be done by someone else. For someone who knows how to write such module it should be fairly easy, as you just need to do one SHA1 calculation (password in the strange Java not-exactly-UTF-16 plus 20 bytes IV from the hash file) and then compare bytes 6 to 19 to a static value delivered in the hash file as well.

The topic came up again due to the @CrackMeIfYouCan challenge, there was a hash in the example set (but not in the challenge).

Please read the POC||GTFO 15 article first, I just reread it myself and I think it is pretty clear on most things.

<!-- gh-comment-id:673308507 --> @floyd-fuh commented on GitHub (Aug 13, 2020): @kholia author of those things here, happy to discuss why you think the cracking speed wouldn't be a lot faster. Instead of putting in the password, "Mighty Aphrodite" and the entire key store file (except the checksum itself, but the file could include hundreds of keys, but of course it depends) in the SHA-1 calculation you only put in the password plus 20 bytes IV. And of course hashing a lot less bytes is faster than hashing a lot more bytes. Another way to look at it is that simply my simple python script was cracking faster than John. Don't crack the keystore password. It is useless. It is only useful if you know it is reused (which you don't know for JKS itself because it's just the default). And even then, the other method is faster. Or even worse: you could be cracking a JKS keystore password, just to never realize that there is no private key in it and you could have extracted all the content without the password (public keys are not encrypted). If john jumbo wants to crack JKS private keys as efficiently as hashcat, you will probably need to replace keystore2john.py with https://github.com/floyd-fuh/JKS-private-key-cracker-hashcat/blob/master/JksPrivkPrepare/JksPrivkPrepare.java and then do a rewrite of the keystore module. If you want me to print the things in JKS-private-key-cracker-hashcat in John format, let me know and I should be able to add a command line switch that outputs john format, I just need to know the format. The keystore cracking module rewrite would need to be done by someone else. For someone who knows how to write such module it should be fairly easy, as you just need to do one SHA1 calculation (password in the strange Java not-exactly-UTF-16 plus 20 bytes IV from the hash file) and then compare bytes 6 to 19 to a static value delivered in the hash file as well. The topic came up again due to the @CrackMeIfYouCan challenge, there was a hash in the example set (but not in the challenge). Please read the POC||GTFO 15 article first, I just reread it myself and I think it is pretty clear on most things.
Author
Owner

@magnumripper commented on GitHub (Aug 16, 2020):

@floyd-fuh unfortunately @kholia is not very active these days (we're hoping for a come-back: He spat out formats like a Gatling gun for many years) and we're awfully short of developers in general. But your input is worth a lot.

Just in case it's not obvious, it would be fantastic if anyone else reading this could contribute!

<!-- gh-comment-id:674570635 --> @magnumripper commented on GitHub (Aug 16, 2020): @floyd-fuh unfortunately @kholia is not very active these days (we're hoping for a come-back: He spat out formats like a Gatling gun for many years) and we're awfully short of developers in general. But your input is worth a lot. Just in case it's not obvious, it would be fantastic if anyone else reading this could contribute!
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#1753
No description provided.