java-deobfuscator / deobfuscator

The real deal
https://javadeobfuscator.com
Apache License 2.0
1.56k stars 290 forks source link

Transformer request #866

Closed ghost closed 2 years ago

ghost commented 2 years ago

A transformer that will force the super keyword to the top of a constructor, where it legally has to be. Some obfuscators move it down on purpose to crash/cause headache for decompilers.

pic 1: as it stands

Screen Shot 2022-01-16 at 2 48 18 PM

pic 2: what is wanted

Screen Shot 2022-01-16 at 2 48 39 PM

If there is an easier way to solve this problem, please tell me.

Janmm14 commented 2 years ago

Not really possible. This is a task of a decompiler. Maybe try to use another decompiler.

What could maybe help is to run the PeepholeOptimizer, It might be able to get rid of some of those unused booleany in fernflower output. Use it at the end.

For the PeepholeOptimizer it might help to run the deobfuscator on the result of the first deobfuscation again with only the PeepholeOptimizer.

If that does not help, you can try out the StackOperationSimplifier I created - you'd just have to build the PR manually: https://github.com/java-deobfuscator/deobfuscator/pull/816

These transformers might be able remove useless instructions before the super call in the constructor and with some luck, Fernflower can then apply syntactic sugar and inline the array creation.

In general, this project's main goal is deobfuscation for later analysis through the use of a decompiler. The second goal is that the created result behaves identical to the original. There is no specific goal to make bytecode superpretty for decompilers.

ItzSomebody commented 2 years ago

Jan's answer pretty much sums up my opinion (and hence why I am classifying this as out-of-scope of the project). Feel free to request general cleanup-related transformers, though.