Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any Object-Oriented Flexible Java x86 Disassembler Library?

I am looking for a Java x86 disassembler library that should have following features:

  • Disassembling X86 Code
  • Describing X86 commands with Java classes and Objects
  • The command classes should accept a visitor which has a generic return value

So, if I have some code that would disassemble like this:

MOV EAX, EBX
CALL 1234
JMP 88

then the library should create three objects for MOV, CALL and JMP. Then I implement a visitor that does diverse things (ex: interpreting, converting to x64 or to an instruction for another processor architecture).

Thanks in advance.

like image 220
belgther Avatar asked Dec 16 '11 08:12

belgther


2 Answers

I don't know about any such library implemented entirely Java. Although, I do heard about distorm disassembler. It is developed in C. But Java wrappers are available for this library. Have a look at it. It may be useful for you.

like image 98
Jomoos Avatar answered Oct 12 '22 10:10

Jomoos


Well, not quite. But there are Java bindings for e.g. Capstone.

Here are maven bindings. Here you can download the native libraries. Here is a Java code example.

// Test.java
import capstone.Capstone;

public class Test {

  public static byte [] CODE = { 0x55, 0x48, (byte) 0x8b, 0x05, (byte) 0xb8,
    0x13, 0x00, 0x00 };

  public static void main(String argv[]) {
    Capstone cs = new Capstone(Capstone.CS_ARCH_X86, Capstone.CS_MODE_64);
    Capstone.CsInsn[] allInsn = cs.disasm(CODE, 0x1000);
    for (int i=0; i<allInsn.length; i++)
      System.out.printf("0x%x:\t%s\t%s\n", allInsn[i].address,
          allInsn[i].mnemonic, allInsn[i].opStr);
  }
}
like image 36
BullyWiiPlaza Avatar answered Oct 12 '22 10:10

BullyWiiPlaza