Decompiling Java Applications

    Decompilation - the process of reconstructing the source code with a decompiler
    I recently wondered: Which decompiler is better?
    Started torturing Google, experimenting. In the end, I found a great solution. How to decompile any program and get working "sources"? About it in a subject.

    A quick tour of popular decompilers


    Mocha

    Mocha (written by Hanpeter van Vliet) is probably one of the first Java decompilers released. Provides a console user interface. Its release took place in 1996, before the Java Development Kit version 1.1 appeared.

    JAva Decompiler

    JAva Decompiler, JAD (author - Pavel Kouznetsov) - Apparently, the most
    popular Java decompiler. Like Mocha, this decompiler provides a console interface, has not been updated or supported for a long time, but a large number of graphical tools for working with it, including the JadClipse plug-in for the Eclipse development environment, make it to this day used as a handy tool for decompilation small classes.
    In addition to decompilation, JAva Decompiler has the ability to disassemble .class files.

    DJ Java Decompiler

    DJ Java Decompiler (author - Atanas Neshkov) - for a long time, contrary to the name, it was only a graphical shell for the previous decompiler, which made it easy and convenient to select command line arguments for calling JAD. The current version adds support for annotations, but the decompiler has become shareware (you need to buy after 10 trial uses).

    Jd-core

    JD-Core (author - Emmanuel Dupuy) is a very powerful and functional library for decompilation and analysis of Java bytecode, developed as part of the "Java Decompiler project".
    It has the following features:
    • Completely written in C ++, which makes decompilation extremely fast
    • It does not require the Java Runtime Environment to work and therefore does not require special installation
    • Decompiles correctly .class files generated by most compilers
    Perhaps the only drawbacks of JD-Core are that it is distributed as
    part of the stand-alone graphical JD-GUI application, also developed in C ++ and linked statically to it, or the JD-Eclipse plug-in for the Eclipse development environment, which makes it almost impossible to use in a third-party nonprofit project, especially developed in the Java language. The use of the library in commercial software products is prohibited by the author.

    Fernflower

    Fernflower is one of the best Java programming language decompilers to date.
    It has the following features:
    1. Supports a variety of language constructs:
    • Parametric Types
    • Annotations
    • Enumerated types
    • Statements
    2. Correctly decompiles the bytecode generated due to some known compiler bugs

    My choice


    1. JD-GUI - for viewing, no more
    2. Fernflower - full recovery

    I will dwell on the second. In general, the author of this decompiler did not seem to upload the offline version to the public (or I missed this fact while reading his blog), until recently it was only online. But it was a pleasant surprise for me to find her on one forum!

    Download: fernflower.jar

    Quote from the author’s blog :
    Fernflower will develop in the direction of the deobfuscator
    ...
    Fernflower does not contain any special deobfuscation functions now, they will be connected in the future by separate modules
    Because the online version for unknown reasons does not work, but it’s hard to say anything about offline (except that the quality of decompilation is excellent), there are no modules at the moment.
    Not yet enough rename module
    That is yes. Let's look for something like this on the Internet.
    Proguard will come to the rescue, but unusual
    ProGuardDeobfuscator is a small modification of the ProGuard program, turning it into a quasi-deobfuscator. During processing, the short obfuscated names of packages, classes, fields, and methods are replaced with more meaningful and unique ones within the Jar file.
    Download the sources and the deobfuscator itself: projectd8.org/Programs/Java/PGD

    There are all the tools, but personally, I use my favorite Netbeans IDE to facilitate the re-creation of the sorts - it helps a lot with my tips, especially when there are a lot of classes.
    Thanks for attention!

    References

    se.math.spbu.ru/SE/YearlyProjects/2011/YearlyProjects/2011/345/345_Mikhailov_report.pdf
    ru-java.livejournal.com

    UPD:
    Sorry, the offline version of Fernflower has a module for renaming and a lot of other things - Readme

    Also popular now: