Search code examples
reverse-engineeringdecompiling

Decompile raw binary code to assembly


I have binary code that I'll like to disassemble to assembly. This code is not part of structured exe or dll file so objdump and gdb do not recognize it.

How can I disassemble it to assembly?


Solution

  • GDB and objdump rely on section information in System V ELF binaries in order to disassemble them. In other words, in order for gdb and objdump to work, the code to be analyzed must be in an ELF binary and that binary must have an intact section header table that accurately describes the layout of the binary.

    How can I decompile it to assembly?

    Decompilation is the reconstruction of source code from a binary. Disassembly is translation of CPU instructions into assembly language.

    I have binary code that I'll like to disassemble to assembly.

    If you have machine code to disassemble and the instruction set architecture of the code is known, one tool that may help is the Capstone disassembly framework. Here is a demo using python bindings: Python tutorial for Capstone.

    Radare2 is another option.

    If this is not helpful, there is a reverse engineering site on StackExchange where you are more likely to find exactly what you need.