Search code examples
javadebuggingobfuscationjvm-argumentsjavaagents

How can I bypass a "-XX:+DisableAttachMechanism" Java VM Option?


I have an obfuscated Java 8 program and I want to attach a Java agent to it. But when I start it with java -javaagent:intrace-agent.jar -jar program.jar it launches and disattaches from the console after a few seconds, my agent finishes. If I try to see program's command line args in Process Explorer, there's a -XX:+DisableAttachMechanism option (this program adds it during startup somehow). Are there any ways to bypass that? Thanks in advance!


Solution

  • There's two approaches you can take to get around that:

    1. Modify the program's bytecode to make it not relaunch itself like that.
    2. Get the OpenJDK source, remove the check that makes that option do anything, and then run the program in that environment.

    Note that with either of those approaches, the program might end up noticing that you did it and doing something else to foil you.