Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAD decompiling issues

Tags:

java

I had a .class file which I wanted to decompile. I tried JAD but it resulted in usual break, goto and return statements which resulted in compilation error in the generated source code by JAD. I had a hard time trying to resolve those compilation errors and everytime I tried to fix a goto statement with return statement, it would introduce other compilation errors.

I then had to hire a freelancer on odesk and the job was done. I wanted to know the exact procedure to be used to decompile the following .class files which can help me and others in future regarding these messy goto, return and break statements added by JAD.

https://drive.google.com/file/d/0ByGLlk1Fq3QIYzVaMGZ4MEVzcjg/edit?usp=sharing

like image 410
Piyush-Ask Any Difference Avatar asked Feb 02 '26 18:02

Piyush-Ask Any Difference


1 Answers

In principle, valid class files can be generated by many more languages than just java, but only class files generated by a standard java compiler can be decompiled into valid java.

To add insult, even class files compiled from java source may not decompile properly, if the code flow is not recognized properly be the decompiler (that may be caused by the original code being very imaginative or the class has been compiled with a compiler that generates byte code not understood by the decompiler). I have experienced that my own code compiled with sun javac 6 would not decompile properly in one case with a nested while loop that had labels and breaks.

The class files may have also been obfuscated precisely to prevent decompilation.

In short, there's no guarantee a class file can be decompiled into valid java code, its not generally the decompilers fault, as one can express code flows in byte code that are impossible to express using plain java.

The generic way to (sort of) decompile such classes is to use javap (or any other tool that can display the byte code) and extract the logic by understanding the byte code yourself, then express the logic in plain java.

like image 174
Durandal Avatar answered Feb 05 '26 08:02

Durandal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!