After experimenting myself, I am convinced that java code obsfucation is not safe in terms of preventing reverse code engineering. So, I turn to using Launch4J to bundle one of my core jar file into a single EXE file. The jar file contains the main entry method as well. Is this going to protect again code reverse engineering?
views:
247answers:
4Does compilng java code to exe (e.g. using Launch4Java) ensure code cannot be reversed engineered?
If a computer can run it, a human can reverse engineer it.
Simply put, you can't prevent your code from being reverse engineered.
- You've already noticed yourself what obfuscation benefits (nothing much, really)
- Class slicing/combining (purposefully mix'n'match various classes to break the logical structure of the code) isn't going to be that helpful either, especially when you have to debug the monstrosity.
- You also can't really encrypt/obfuscate the bytecode either because after the bytecode has hit your custom ClassLoader, it's already back in completely readable format. More information here.
Even if you'd get the code protected, it can be monitored. Maybe on bytecode level, maybe on ASM level, that doesn't matter - what matters is that when one can monitor the code being executed, it can also be reverse engineered. Some methods do take more time than others but there isn't a case where it would be impossible.
Stop thinking in the terms of security through obscurity and instead start analyzing the real security etc. issues you have and fix them accordingly. Preventing reverse engineering - even if it wouldn't be an exercise in futility - isn't going to magically fix the problems of your software.
Launch4J doesn't translate your Java code into native executable code, it just provides a native launcher that looks for a JDK and has your JAR as a resource (either packaged inside the executable or not). This is just a convenience - not security. If your JAR is external to the executable, someone can reverse engineer your code like a regular Java application. If your JAR is packaged into the executable - Presumably, someone programmed the logic to wrap the JAR in the executable, and someone can program the logic to unwrap the JAR from the executable (or use one of many tools that can extract resources from executables) - and can then reverse engineer your code like a regular Java application.