

What's New?
and a commercial license.
distorm
Powerful Disassembler Library For AMD64.Showcase
This is a really simple example of how to use diStorm and how the results look, so you get the idea. We take a compiled C function and show how it gets once disassembled and once again decomposed. It shows all the fields of the binary structures you get from using diStorm. Users are strongly advised to read the documentation in order to use diStorm with all its glory. For more information about using the decode API, refer to the C Sample page. And for the decompose API refer to the Decompose Interface.Compiled and assembled to:
bin =
0x55 0x8b 0xec 0x8b 0x45 0x08 0x03 0x45 0x0c 0xc9 0xc3
Basic API distorm_decode usage example:
_DecodeResult res;
_DecodedInst disassembled[MAX_INSTRUCTIONS];
unsigned int decodedInstructionsCount = 0;
_OffsetType offset = 0;
res = distorm_decode(offset,
(const unsigned char*)bin,
sizeof(bin),
Decode32Bits,
disassembled,
MAX_INSTRUCTIONS,
&decodedInstructionsCount);
for (int i = 0; i < decodedInstructionsCount; i++) {
printf("%08I64x (%02d) %-24s %s%s%s\r\n",
disassembled[i].offset,
disassembled[i].size,
(char*)disassembled[i].instructionHex.p,
(char*)disassembled[i].mnemonic.p,
disassembled[i].operands.length != 0 ? " " : "",
(char*)disassembled[i].operands.p);
}
Output:
00000000 (01) 55 PUSH EBP
00000001 (02) 8bec MOV EBP, ESP
00000003 (03) 8b4508 MOV EAX, [EBP+0×8]
00000006 (03) 03450c ADD EAX, [EBP+0xc]
00000009 (01) c9 LEAVE
0000000a (01) c3 RET
Since this is the basic API, you only get the address of the instruction, its size in bytes, the textual mnemonic, textual operands and the bytes of the instruction in hex.
The following is a dump of the returned array of _DecodedInst structures.
Dump of the disassembled array:
- disassembled[0]
+ mnemonic {length=4 p="PUSH" }
+ operands {length=3 p="EBP" }
+ instructionHex {length=2 p="55" }
size 1
offset 0
- disassemled[1]
+ mnemonic {length=3 p="MOV" }
+ operands {length=8 p="EBP, ESP" }
+ instructionHex {length=4 p="8bec" }
size 2
offset 1
- disassembled[2]
+ mnemonic {length=3 p="MOV" }
+ operands {length=14 p="EAX, [EBP+0x8]" }
+ instructionHex {length=6 p="8b4508" }
size 3
offset 3
- disassembled[3]
+ mnemonic {length=3 p="ADD" }
+ operands {length=14 p="EAX, [EBP+0xc]" }
+ instructionHex {length=6 p="03450c" }
size 3
offset 6
- disassembled[4]
+ mnemonic {length=5 p="LEAVE" }
+ operands {length=0 p="" }
+ instructionHex {length=2 p="c9" }
size 1
offset 9
- disassembled[5]
+ mnemonic {length=3 p="RET" }
+ operands {length=0 p="" }
+ instructionHex {length=2 p="c3" }
size 1
offset 10
New API distorm_decompose example:
The distorm_decompose function requires to set up a tiny structure with the relevant binary stream to decompose.- decomposed[0]
addr 0
size 1
flags 1280 – FLAG_GET_OPSIZE(1280): Decode32Bits, FLAG_GET_ADDRSIZE(1280): Decode32Bits
segment R_NONE
base R_NONE
scale 0
dispSize 0
opcode I_PUSH
- ops[0]
type O_REG
index R_EBP
size 32
disp 0
imm 0
unusedPrefixesMask 0
meta 8 – META_GET_ISC(8): ISC_INTEGER
usedRegistersMask 32
- decomposed[1]
addr 1
size 2
flags 1344 – FLAG_DST_WR, FLAG_GET_OPSIZE(1280): Decode32Bits, FLAG_GET_ADDRSIZE(1280): Decode32Bits
segment R_NONE
base R_NONE
scale 0
dispSize 0
opcode I_MOV
- ops[0]
type O_REG
index R_EBP
size 32
- ops[1]
type O_REG
index R_ESP
size 32
disp 0
imm 0
unusedPrefixesMask 0
meta 8 – META_GET_ISC(8): ISC_INTEGER
usedRegistersMask 48
- decomposed[2]
addr 3
size 3
flags 1344 – FLAG_DST_WR, FLAG_GET_OPSIZE(1280): Decode32Bits, FLAG_GET_ADDRSIZE(1280): Decode32Bits
segment 198 – SEGMENT_IS_DEFAULT(198): TRUE, SEGMENT_GET(198): R_SS
base R_NONE
scale 0
dispSize 8
opcode I_MOV
- ops[0]
type O_REG
index R_EAX
size 32
- ops[1]
type O_SMEM
index R_EBP
size 32
disp 8
imm 0
unusedPrefixesMask 0
meta 8 – META_GET_ISC(8): ISC_INTEGER
usedRegistersMask 33
- decomposed[3]
addr 6
size 3
flags 1344
segment 198 – SEGMENT_IS_DEFAULT(198): TRUE, SEGMENT_GET(198): R_SS
base R_NONE
scale 0
dispSize 8
opcode I_ADD
- ops[0]
type O_REG
index R_EAX
size 32
- ops[1]
type O_SMEM
index R_EBP
size 32
disp 12
imm 0
unusedPrefixesMask 0
meta 8 – META_GET_ISC(8): ISC_INTEGER
usedRegistersMask 33
- decomposed[4]
addr 9
size 1
flags 1280 – FLAG_GET_OPSIZE(1280): Decode32Bits, FLAG_GET_ADDRSIZE(1280): Decode32Bits
segment R_NONE
base R_NONE
scale 0
dispSize 0
opcode I_LEAVE
ops 0
disp 0
imm 0
unusedPrefixesMask 0
meta 8 – META_GET_ISC(8): ISC_INTEGER
usedRegistersMask 0
- decomposed[5]
addr 10
size 1
flags 1280 – FLAG_GET_OPSIZE(1280): Decode32Bits, FLAG_GET_ADDRSIZE(1280): Decode32Bits
segment R_NONE
base R_NONE
scale 0
dispSize 0
opcode I_RET
ops 0
disp 0
imm 0
unusedPrefixesMask 0
meta 10 – META_GET_ISC(10): ISC_INTEGER, META_GET_FC(10): FC_RET
usedRegistersMask 0
Overview
Today with quickly evolving malware and viruses you have to analyze more code, accurately and faster. diStorm is a great solution to integrate in your binary code analysis algorithms. It is already being used in many open source projects, API hooking libraries, shellcode-searching, binary code-analysis and other fields. diStorm has been an open source project since its beginning in 2005, it is very robust and mature and being used widely all over the world. diStorm is the fastest disassembler in the world and is still highly maintained and updated by its creator.
Publications
Appearances in Books
Fuzzing has evolved into one of today?s most effective approaches to test software security. To ?fuzz,? you attach a program?s inputs to a source of random data, and then systematically identify the failures that arise. Hackers have
relied on fuzzing for years: Now, it?s your turn. In this book, renowned fuzzing experts...
Defend against the ongoing wave of malware and rootkit assaults the failsafe Hacking Exposed way. Real-world case studies and examples reveal how today's hackers use readily available tools to infiltrate and hijack systems. Step-by-step countermeasures provide proven prevention techniques.