Skip to content

Commit 5bb07b3

Browse files
author
plasma-disassembler
committed
fix #89: different output with capstone 4.0
- X86_OP_FP removed - some operands are now interpreted as int instead of char
1 parent 8ec3bb7 commit 5bb07b3

File tree

11 files changed

+21
-21
lines changed

11 files changed

+21
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ database compatibility could be broken.
2121
## Requirements
2222

2323
* python >= 3.4
24-
* [capstone](https://github.com/aquynh/capstone)
24+
* [capstone](https://github.com/aquynh/capstone), tested with 4.0-alpha5
2525
* [python-pyelftools](https://github.com/eliben/pyelftools)
2626
* [pefile](https://github.com/erocarrera/pefile) + python3-future
2727
* [python-msgpack](https://github.com/msgpack/msgpack-python) >= 0.4.6

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [ "$1" != "--update" ]; then
3131
pushd . > /dev/null
3232
mkdir -p build
3333
cd build
34-
CAPSTONE_VERSION="3.0.5-rc3"
34+
CAPSTONE_VERSION="4.0-alpha5"
3535
if [ -d capstone_$CAPSTONE_VERSION ]; then
3636
cd capstone_$CAPSTONE_VERSION
3737
make clean

plasma/lib/arch/x86/output.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from capstone.x86 import (X86_INS_ADD, X86_INS_AND, X86_INS_CMP, X86_INS_DEC,
2121
X86_INS_IDIV, X86_INS_IMUL, X86_INS_INC, X86_INS_MOV, X86_INS_SHL,
22-
X86_INS_SHR, X86_INS_SUB, X86_INS_XOR, X86_OP_FP, X86_OP_IMM,
22+
X86_INS_SHR, X86_INS_SUB, X86_INS_XOR, X86_OP_IMM,
2323
X86_OP_INVALID, X86_OP_MEM, X86_OP_REG, X86_REG_EBP, X86_REG_EIP,
2424
X86_REG_RBP, X86_REG_RIP, X86_INS_CDQE, X86_INS_LEA, X86_INS_MOVSX,
2525
X86_INS_OR, X86_INS_NOT, X86_PREFIX_REP, X86_PREFIX_REPNE,
@@ -85,8 +85,8 @@ def inv(n):
8585
elif op.type == X86_OP_REG:
8686
self._add(i.reg_name(op.value.reg))
8787

88-
elif op.type == X86_OP_FP:
89-
self._add("%f" % op.value.fp)
88+
# elif op.type == X86_OP_FP:
89+
# self._add("%f" % op.value.fp)
9090

9191
elif op.type == X86_OP_MEM:
9292
mm = op.mem

tests/analyzer/arrays.rev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ frame_size = 8
4141
0x400470: eax = unk_600a2f
4242
0x400475: push rbp
4343
0x400476: rax -= __TMC_END__
44-
0x40047c: rax cmp '\x0e'
44+
0x40047c: rax cmp 14
4545
0x400480: rbp = rsp
4646
0x400483: jbe loc_4004a0
4747
0x400485: eax = 0

tests/analyzer/overlap.rev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function overlap_2 (.text) {
2626
0x4000f6: ecx++
2727
# 0x4000f8: cmp ecx, 0xf
2828
# 0x4000fb: jle 0x4000f1
29-
if (ecx > '\x0f') goto break_0x4000fd
29+
if (ecx > 15) goto break_0x4000fd
3030
} ; loop
3131

3232
break_0x4000fd:

tests/analyzer/regsim.rev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ frame_size = 8
2525

2626
loop:
2727
0x4000e9: rax += 1
28-
0x4000ed: rax cmp '\n'
28+
0x4000ed: rax cmp 10
2929
0x4000f1: jne loop
3030
0x4000f3: rbx = 10
3131
0x4000fa: rax = rbx + 4194467

tests/analyzer/switch.rev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ frame_size = 8
3737
0x400440: eax = unk_6009df
3838
0x400445: push rbp
3939
0x400446: rax -= __TMC_END__
40-
0x40044c: rax cmp '\x0e'
40+
0x40044c: rax cmp 14
4141
0x400450: rbp = rsp
4242
0x400453: jbe loc_400470
4343
0x400455: eax = 0
@@ -175,7 +175,7 @@ int var_c = -0xc
175175
0x400515: var_c cmp 10
176176
0x400519: ja loc_400564
177177
0x40051b: eax = var_c
178-
0x40051e: !rax = &jmptable_400620[0]
178+
0x40051e: rax = *((rax*8) + &jmptable_400620[0])
179179
0x400526: jmp rax ; switch statement jmptable_400620[11]
180180

181181
; case 2 jmptable_400620

tests/andor5.rev

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ function main (.text) {
99
0x4004f4: call rand
1010
0x4004f9: ebx = eax
1111
0x4004fb: call rand
12-
0x400500: ebx cmp '\x01'
12+
0x400500: ebx cmp 1
1313
0x400503: ebp = eax
1414
# 0x400505: je 0x400515
1515
if != {
1616
# 0x400507: cmp eax, 1
1717
# 0x40050a: je 0x400524
18-
if (eax == '\x01') {
18+
if (eax == 1) {
1919
goto 0x400524
2020
}
2121
} else {
2222
0x400515: edi = 0x4006b4 "2"
2323
0x40051a: call puts
2424
# 0x40051f: cmp ebp, 2
2525
# 0x400522: jne 0x40050c
26-
if (ebp == '\x02') {
26+
if (ebp == 2) {
2727
0x400524: edi = 0x4006b6 "1"
2828
0x400529: call puts
2929
0x40052e: jmp ret_0x40050c

tests/andor6.rev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ function main (.text) {
99
0x4004f6: call rand
1010
# 0x4004fb: cmp ebx, 1
1111
# 0x4004fe: je 0x400513
12-
if (ebx != '\x01') {
12+
if (ebx != 1) {
1313
0x400500: edi = 0x4006b6 "2"
1414
0x400505: call puts
1515
# 0x40050a: cmp ebx, 2
1616
# 0x40050d: je 0x400517
17-
if (ebx == '\x02') {
17+
if (ebx == 2) {
1818
goto 0x400517
1919
}
2020
} else {

tests/pendu____main.rev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ function ___main (.text) {
1010
0x4018d0: eax = *(___CTOR_LIST__)
1111
0x4018d5: ebx = 1
1212
0x4018da: *(0x404020) = ebx
13-
# 0x4018e0: cmp eax, 0xff
13+
# 0x4018e0: cmp eax, -1
1414
# 0x4018e3: je 0x40190a
15-
if (eax == '\xff') {
15+
if (eax == -1) {
1616
0x40190a: ecx = *(0x401e94)
1717
0x401910: eax = 0
1818
0x401912: test ecx, ecx

0 commit comments

Comments
 (0)