I am currently trying to extract all opcodes from PE files. I am wondering what the difference between Radare2's "pd" command which "disassemble N bytes" and the "pda" command which "disassemble all possible opcodes (byte per byte)". Which command should I use to find all the opcodes from a PE file?
Asked
Active
Viewed 186 times
1 Answers
1
It depends on what you mean by all opcodes. x861 is a CISC architecture. Not all instructions have the same size.
Consider the following byte sequence:
55 48 89 e5
which corresponds to
55 push rbp
4889e5 mov rbp, rsp
in x86 64bit. And that's what you get with pd
(if you start at the beginning). However, there is an other opcode hidden in this byte sequence, namely 89 e5
which is mov ebp, esp
. pdA
will also reveal this.
0 55 push rbp
1 4889e5 mov rbp, rsp
2 89e5 mov ebp, esp
3 e5 <invalid>
In pdA
r2 always increments by a byte an tries to disassemble an opcode.
1 Since you want to analyze PEs I assume you use x86_64

Liblor
- 480
- 5
- 13