BuringStraw

BuringStraw

Do not move the jar file, modify the Java class through the Java agent.

During the offline AWD competition in Liaoning Province, there was a Java question:

Unfortunately, only three teams were able to solve it. We ranked fourth because we didn't know how to fix it (thankfully, we had jadx-gui on Kali, but why can we only view it and not modify it?!).

After some research, I found out about this thing called Java Agent, which can achieve a similar effect to hooking (although it doesn't seem as good as Xposed). However, there seem to be many pitfalls and environmental issues, so I decided to document it.

First, the least important part of the code was referenced from here, with some modifications for precise searching of overloaded functions (you can also find an introduction to Java Agent here): https://www.cnblogs.com/rickiyang/p/11368932.html

Pitfalls:

Download javassist.jar.

Then, he used Maven to modify the manifest, but I couldn't find a way to include the dependencies in the package, so I switched to Ant.

I used NetBeans as my IDE. You can directly right-click on Libraries and add the JAR.

To modify the manifest, refer to this link: https://www.javaxt.com/wiki/Tutorials/Netbeans/How_to_Add_Version_Information_to_a_Jar_File_with_Netbeans

However, this part is not quite right:

First, you must update your Netbeans "project.properties" file found in the "nbproject" directory. Add the following line to the file:

manifest.file=manifest.mf

Instead, you should change manifest.file=manifest.mf in project.properties to manifest.file=MANIFEST.MF.

In addition to Premain-Class and Agent-Class, two more lines need to be added to the manifest (remember to delete all the messy properties he wrote):

Although Ant didn't include the dependencies in the package, he created a lib directory and added the classpath attribute to the manifest, so it can still run.

The startup command is java -javaagent:'/home/zfn/NetBeansProjects/agent2/dist/agent2.jar' -jar awd.jar

Good.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.