40 Chernov-Troshina
40 Chernov-Troshina
40 Chernov-Troshina
• SmartDec decompiler
• Academic background
• Defended Ph.D.
• Industry
Once upon a time…
sub1: …
CALL subn # absolute address
…
RET
sub2: … # follows RET
RET
subn: … # follows RET
RET
CALL heuristics
• Search result:
Candidate opcode: 000b000c
total: 82, hits: 7, misses: 0 adds: 0400 65a8 668e
Candidate opcode: 004e000b
total: 352, hits: 1, misses: 0 adds: 37c6
Candidate opcode: 004e00bf
total: 82, hits: 3, misses: 0 adds: 39b4
Candidate opcode: 00d8008c
total: 29, hits: 5, misses: 0 adds: 311c 5232
Search results:
Candidate opcode: 1c00
total: 207, hits: 92, misses: 0, xrets = 12
Candidate opcode: (0b00) 2c00
total: 159, 0b_prefixed: 2, hits: 55, misses: 0, xrets = 19
Candidate opcode: (0b00) 3c00
total: 78, 0b_prefixed: 2, hits: 36, misses: 0, xrets = 20
Candidate opcode: 4c00
total: 81, hits: 40, misses: 0, xrets = 5
Candidate opcode: (0b00) 5c00
total: 93, 0b_prefixed: 2, hits: 43, misses: 0, xrets = 12
Candidate opcode: (0b00) 6c00
total: 182, 0b_prefixed: 2, hits: 72, misses: 0, xrets = 5
Candidate opcode: (0b00) 7c00
total: 147, 0b_prefixed: 1, hits: 81, misses: 0, xrets = 23
Assumption: these are relative conditional jumps
Intermediate results
• Instructions identified:
– CALL
– RET
– JMP
– Conditional JMPs
• High-byte extenstion prefix is
identified
• Control-flow graph can be built and
the general structure can be identified
Cond. arithmetics heuristics
• Search results:
Jump opcode 1c (207)
Opcode: 1a
0001: 1
0002: 1
...
0100: 1
0200: 1
1000: 1
4000: 1
...
Arith. refinement
• Often used:
0bHH 3fLL 0f00
• Corresponds to
MOV DP0, HHLL
MOV @DP0, 0
Arithmetics search results
• Known operations:
5a01 SUB ACC, 1
->
???? SUB ACC, R0
Operation encoding
• Known MOVs:
890f MOV R0, @DP0
990f MOV R1, @DP0
8f09 MOV @DP0, R0
8f19 MOV @DP0, R1
0f00 MOV @DP0, 0
->
8919 MOV R0, R1
9909 MOV R1, R0
0900 MOV R0, 0
1901 MOV R1, 1
• Known operations:
5a01 SUB ACC, 1
->
da09 SUB ACC, R0
Register structure
• It is possible to discover
– Subroutine structure
– Unconditional and conditional jumps
– Some arithmetic instructions
– Rough register structure
• Only by binary analysis of the code
without virtual machine (processor)
data sheets
Limitations
• No obfuscation
• Most subroutines follow each other
Tool support
annotations
• Opcode specifications
• Specification of code and data areas
• Entry points
• Symbolic cell names
• Subroutine range and description
• Inline and outline specifications
SmartDec decompiler
Questions?
info@decompilation.info