百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
J

JKS-private-key-cracker-hashcat

> 编程语言
开源

在 JKS 保存箱中植入钉子 - 破解 JKS 文件中的私钥条目的密码

188 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

在 JKS 保存箱中植入钉子 - 破解 JKS 文件中的私钥条目的密码

JKS private key cracker - Nail in the JKS coffin

The Java Key Store (JKS) is the Java way of storing one or several cryptographic private and public keys for asymmetric cryptography in a file. While there are various key store formats, Java and Android still default to the JKS file format. JKS is one of the file formats for Java key stores, but JKS is confusingly used as the acronym for the general Java key store API as well. This project includes information regarding the security mechanisms of the JKS file format and how the password protection of the private key can be cracked. Due the unusual design of JKS the developed implementation can ignore the key store password and crack the private key password directly. Because it ignores the key store password, this implementation can attack every JKS configuration, which is not the case with most other tools. By exploiting a weakness of the Password Based Encryption scheme for the private key in JKS, passwords can be cracked very efficiently. Until now, no public tool was available exploiting this weakness. This technique was implemented in hashcat to amplify the efficiency of the algorithm with higher cracking speeds on GPUs.

To get the theory part, please refer to the POC||GTFO article "15:12 Nail in the Java Key Store Coffin" in issue 0x15 included in this repository (pocorgtfo15.pdf) or available on various mirros like this beautiful one: https://unpack.debug.su/pocorgtfo/

Before you ask: JCEKS or BKS or any other Key Store format is not supported (yet).

How you should crack JKS files

The answer is build your own cracking hardware for it ;) . But let's be a little more practical, so the answer is using your GPU:

    _____:  _____________         _____:  v3.6.0     ____________
   _\    |__\______    _/_______ _\    |_____ _______\______    /__ ______
   |     _     |  __   \   ____/____   _     |   ___/____  __    |_______/
   |     |     |  \    _\____      /   |     |   \      /  \     |     |
   |_____|     |______/     /     /____|     |_________/_________:     |
         |_____:-aTZ!/___________/     |_____:                 /_______:
 
* BLAKE2 * BLOCKCHAIN2 * DPAPI * CHACHA20 * JAVA KEYSTORE * ETHEREUM WALLET *

All you need to do is run the following command:

java -jar JksPrivkPrepare.jar your_JKS_file.jks > hash.txt

If your hash.txt ends up being empty, there is either no private key in the JKS file or you specified a non-JKS file.

Then feed the hash.txt file to hashcat (version 3.6.0 and above, but if you want to be on the safe side and also make sure you can crack very long passwords please use at least version 4 of hashcat!), for example like this:

…

So from this repository you basically only need the JksPrivkPrepare.jar to run a cracking session.

From John The Ripper format to the hashcat format

This information is only important to CTF players or hash cracking competition players. In real life you should have access to the JKS file and just use JksPrivkPrepare.jar. However, when you get an artifical challenge, you sometimes only get the "John the Ripper" hash format from keystore2john.py. I'll explain how you can get from the "John" format to the original JKS file (yes, the entire file is in the john hash format). Let's look at an example:

…

You will need to extract the part starting with "feedfeed" and the next part (44f13fd07f8bd5fb219aac5578081d72cfc89272) from the john format, append them to each other (in this order), hex decode it and store it into a file. So for the above example:

…

Now you can use JksPrivkPrepare.jar on that original_jks_file.jks you just created, just like you would on any JKS file:

…

Other things in this repository

  • test_run.sh: A little test script that you should be able to run after a couple of minutes to see this project in action. It includes comments on how to setup the dependencies for this project.
  • benchmarking: tests that show why you should use this technique and not others. Please read the "Nail in the JKS coffin" article.
  • example_jks: generate example JKS files
  • fingerprint_creation: Every plaintext private key in PKCS#8 has it's own "fingerprint" that we expect when we guess the correct password. These fingerprints are necessary to make sure we are able to detect when we guessed the correct password. Please read the "Nail in the JKS coffin" article. This folder has the code to generate these fingerprints, it's a little bit hacky but I don't expect that it will be necessary to add any other fingerprints ever.
  • JksPrivkPrepare: The source code of how the JKS files are read and the hash calculated we need to give to hashcat.
  • jksprivk_crack.py: A proof of concept implementation that can be used instead of hashcat. Obviously this is much slower than hashcat, but it can outperform John the Ripper (JtR) in certain cases. Please read the "Nail in the JKS coffin" article.
  • jksprivk_decrypt.py: A little helper script that can be used to extract a private key once the password was correctly guessed.
  • run_example_jks.sh: A script that runs JksPrivkPrepare.jar and jksprivk_crack.py on all example JKS files in the example_jks folder. Make sure you run the generate_examples.py in example_jks script before.

Related work and further links

A big shout to Casey Marshall who wrote the JKS.java class, which is used in a modified version in this project:

…

Various more information which are mentioned in the article as well:

  • JKS is going to be replace as the default type in Java 9 http://openjdk.java.net/jeps/229
  • https://gist.github.com/zach-klippenstein/4631307
  • http://www.openwall.com/lists/john-users/2015/06/07/3
  • https://github.com/bes/KeystoreBrute
  • https://github.com/jeffers102/KeystoreCracker
  • https://github.com/volure/keystoreBrute
  • https://gist.github.com/robinp/2143870
  • https://www.darknet.org.uk/2015/06/patator-multi-threaded-service-url-brute-forcing-tool/
  • https://github.com/rsertelon/android-keystore-recovery
  • https://github.com/MaxCamillo/android-keystore-password-recover
  • https://cryptosense.com/mighty-aphrodite-dark-secrets-of-the-java-keystore/
  • https://hashcat.net/events/p12/js-sha1exp_169.pdf
  • https://github.com/hashcat/hashcat

Neighborly greetings go out to atom, vollkorn, cem, doegox, corkami, xonox and rexploit for supporting this research in one form or another!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言