I am working on a deobfuscator for an application which is heavily obfuscated. There are a lot of redundant methods which I would like to remove to simplify the code. Unfortunately, I don't have enough knowledge with asm and bytecode to be able to do this, could someone please enlighten me on how I would use asm to check for methods that are called?
1 Answer
Gathering a list of methods that are called by a class is straightforward. If you are using the ASM sax api then just override
public void visitMethodInsn(int opcode, String owner, String name, String desc)
And collect the method name, owners and signatures.
If you use the tree api the same information will be available from the MethodInsnNodes.
Generating a list of methods a class declares/defines is similarly straight forward - each one will result to a call to visitMethod or a method node in the tree api.
javap -cand poking through the output of that should also be helpful.