02. Attaching the Debugger Without the Source - ThisTestUser/Java-Debugger GitHub Wiki
Sometimes, you'll want to debug an application that you don't have the source to. In that case, you need to use a bytecode editing software to inject the Debugger in. I highly recommend using JByteMod or Recaf, as they are updated for the latest versions of Java.
In order to do this, you'll have to know some basic knowledge of bytecode. You can learn by decompiling programs using Bytecode Viewer and checking the bytecode.
The image above shows the function DebuggerHook.injectDebugger(this, null)
being injected into the constructor of the class. The aload0
loads the first local variable (which is "this" in non-static methods), aconst_null
loads a null into the stack, and invokestatic
calls the method "injectDebugger" using the arguments.
After the changes are made, save the JAR file and drag the contents of Debugger.jar into the application JAR. The application should run normally, and if it crashes in a VerifyError then add -noverify
the the JVM or only save the classes you modified (drag modified classes from output JAR into original JAR). If any other errors appear, this means you messed up the bytecode in some way.