How to Debug JVM Bytecode Without Debug Information: Tools and Strategies?
Asked by
!static.test
I'm currently working on a university project that involves debugging JVM bytecode from production applications. The catch is that I'm focusing on cases where the bytecode has been stripped of debugging informationโlike the LineNumberTable, LocalVariableTable, and StackMapTableโand I don't have access to the original source code. I'm looking for insights into manual dynamic analysis of this kind of bytecode. How often do you find yourselves in this situation? What specific use cases can you share? What tools do you recommend for this? Are you using anything publicly available or developed in-house? It's common for release JARs to go through these processes, often after being optimized or obfuscated by tools like ProGuard. I know traditional Java debugging provides certain insights with debug info, but I'm curious about how to handle scenarios where that data is missing. Also, legally, I understand there are permissible reasons to analyze and modify licensed softwareโsuch as fixing bugs or creating compatible productsโbut I'd love to get your thoughts on all this!
Answers
I faced a similar challenge while working on my dissertation. I had to reverse-engineer an Android app to add a feature that wasnโt originally there. Instead of decompiling everything, I focused on extracting specific functions, getting them to a compilable state, and then recompiling them as if they were external dependencies. This let me make targeted changes without having to fix the app as a whole. Later, I used the Xposed Framework to hook into my banking appโs authentication mechanism to build a custom dashboard. By analyzing the bytecode, I could set hooks to capture and understand the data flow. Java Agents could also help with this kind of debugging, as tools like ByteBuddy let you modify bytecode at runtime.
Reply to this answer
Have you tried JDBG? Itโs a Windows-only tool. You might be able to somewhat reconstruct the LineNumberTable and LocalVariableTable through careful analysis of method instructions, though getting line numbers right can be tricky. If you can track how instructions are built into the final AST model, you might be able to insert line number entries back in. Some decompilers, like FernFlower, might offer similar capabilities, but they have limitations too.
audit7trail: Yeah, I downloaded JDBG but couldn't get it to work even for applications with debug info. Did you have any luck with it?
relay.runner.ready: I tried some static analysis too, but youโre rightโit can often be inaccurate, especially when dealing with complex bytecode.
Reply to this answer
Iโve had some experience debugging native libraries, but I havenโt dealt much with obfuscated JARs. Itโs tricky when you do get into unknown bytecode territory! You often have to rely on examining the state at method entry and then hooking calls to validate whatโs going on.
Reply to this answer
I once had to recompile a legacy JAR when the source code was lost after 20 years. It was a small but crucial application, and we were only able to understand its logic after analyzing the bytecode. After matching the data processes, we managed to migrate the system into a modern solution without issues. It's wild looking back to see how everything came together without any documentation!
Reply to this answer
Add your answer
Answers are reviewed before publication.
how_about_thursday: That's interesting! But isnโt Android now using DEX instead of JVM bytecode? Iโve heard ART handles the execution differently now. How does that affect reverse engineering tools?
SUNDAY_brunch: Youโre right! The hooking methods can be similar because of their shared background, but I think Java Agents have a lot of potential for traditional JVM work, too.