How can I dump the assembly of main function of binary(not striped) in ubuntu?

I want to see the assembly command and the hex value of this command

There are 1 binary for arm and 1 binary for x86

  • 1
    What tool do you use? – Paweł Łukasik Feb 3 '20 at 17:36
  • @Paweł Łukasik I looking for tool ... – wfj96649BcaooCom Feb 3 '20 at 17:54
  • 1
    Ghidra, ida, r2 ... – Paweł Łukasik Feb 3 '20 at 17:58
  • Ida free cant preset disassembly for Arm.(is there Ida for linux?) Is there any simple and free tool? – wfj96649BcaooCom Feb 3 '20 at 18:07
  • 1
    there was nothing about tool being free in the question, but Ghidra and r2 are free... – Paweł Łukasik Feb 3 '20 at 22:30

In your Ubuntu terminal, go to the directory where the file is located and type this:

objdump -M intel -D name-of-file | grep -A20 main.:

(assuming you want intel assembly since it's easier to read but if not, remove "-M intel" from the command above.)

This should show you the first twenty lines of your main function. objdump should skip a line after a function is over, so keep adding to the number after -A til you see the whole function followed by a blank line.

  • 1
    Not contend with the default AT&T syntax? ... neither am I. I find it harder to read. Well done, have an upvote. – 0xC0000022L Feb 5 '20 at 9:40

In order to view the assembly from any function of a compiled binary you will need a disassembler. There are many disassemblers that can be used for this function including:

  • IDA Pro (Commercial)

  • Ghidra (Open Source)

  • Radare2 (Open Source)

    To use these tools you will usually just load the binary into the software and it will present you with the assembly representation of the binary using various algorithms such as Linear Sweep and Recursive traversal.

Alternatively you can always open the binaries within a hex editor and extract the OP codes from HEX. However the challenge would be to locate your target location in the binary.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.