1

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?

7
  • 6
    Your answer is obvious: get more knowledge about ASM and bytecode. Both have documentation available. Decompiling the application (or any Java code) with javap -c and poking through the output of that should also be helpful. Commented Aug 18, 2013 at 22:54
  • It's probably impossible to detect if a method is ever called or not if the application uses reflection to call those methods. Commented Aug 18, 2013 at 23:28
  • It doesn't use reflection, I know that much. Commented Aug 18, 2013 at 23:33
  • Have you tried using Krakatau? It's pretty good for deobfuscation. Unfortunately, it's not well documented, but if you have any questions you can always ask me. Commented Aug 19, 2013 at 0:18
  • Ah you're the same guy from yesterday :P I would use Krakatau BUT that goes against the purpose of me making a deobfuscator.. Commented Aug 19, 2013 at 0:38

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.