Jar Files

If we have Java files, such as one from the blockyBlocky Writeup machine, which is BlockyCore.class
We need to decompile it to see the content.
To do this, we can do

wget https://www.benf.org/other/cfr/cfr-0.152.jar
# Now we do
java -jar cfr-0.152.jar BlockyCore.class

And we see the contents.
We can also decompile them recursively.

So

java -jar cfr-0.152.jar jar_content --outputdir decompiled_code

✅ Step-by-step guide to decompile .class recursively with cfr

1. 📦 Install cfr (if you don’t have it)

You can download it from:
👉 https://github.com/leibnitz27/cfr/releases

Save it as cfr.jar for example.


2. 🧠 Decompiles everything recursively:

java -jar cfr.jar directory/path -o output/path --outputdir ./sources

🔹 Example:

java -jar cfr.jar ./com --outputdir ./sources

This decompiles all .class inside ./com/ (recursively) and puts the .java in ./sources.


✅ Quick alternative with find and loop (if you use another decompiler like jad, procyon, etc.)

find ./ -name "*.class" -exec java -jar cfr.jar {} --outputdir ./sources \;

This does it file by file, but it’s slower than letting cfr traverse the tree.


🧩 Extra Tip

If you’re doing this in CTF or pentesting (like in HTB), you typically do:

unzip file.jar -d jar_contents cd jar_contents java -jar ~/tools/cfr.jar . --outputdir ../decompiled

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top