TLDR I want to do live debugging of a java program on a linux machine, and don't how/what debugger to attach to the JVM to get this done.
I expect that this is a well-solved problem, but I lack the terminology to find a solution after several hours of searching:
I have a java program (stored in a jar file) that I'd like to observe (reverse engineer?) it while it runs. I see a lot of decompilation support for java - this isn't what I'm interested in at all, so please refrain from explaining how to do this. A major problem I'm having in my search is running into these kinds of answer.
- Start the program and find the PID.
- Attach a debugger to the JVM somehow (this is what I don't know how to do, and lack the language to search for, apparently)
- Use the debugger to set breakpoints, read/write arbitrary memory of the JVM, see the JVM's registers and stack.
- Use a simple, open-source command-line tool to do this, like Radare2 or GDB.
I expect to be reading java bytecode (the instruction set for the JVM), not java source, while I do this.
I am used to using Radare2 and GDB for native code (crackmes, CTF stuff, microcorruption). I also see that they both technically support Java, but I'm having a hard time figuring out how to do this, exactly.
I need help with 2 things: what software to use and how to attach the program to the process. Bonus points if I can use radare!
To be clear, the Java in question is running on a linux PC, not on an Android phone or anything like that.
I also read about JDB, but it seems like the code needs to be compiled with debug flags, and this is not possible for my situation -- it also doesn't seem like what I'm looking for.