how to import capstone in python

Solutions on MaxInterview for how to import capstone in python by the best coders in the world

showing results for - "how to import capstone in python"
Valentina
27 Apr 2017
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
1616
1717
1818
1919
2020
2121
2222
2323
24from capstone import *
25from capstone.arm import *
26
27CODE = b"\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3"
28
29md = Cs(CS_ARCH_ARM, CS_MODE_ARM)
30md.detail = True
31
32for i in md.disasm(CODE, 0x1000):
33    if i.id in (ARM_INS_BL, ARM_INS_CMP):
34        print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
35
36        if len(i.regs_read) > 0:
37            print("\tImplicit registers read: "),
38            for r in i.regs_read:
39                print("%s " %i.reg_name(r)),
40            print
41
42        if len(i.groups) > 0:
43            print("\tThis instruction belongs to groups:"),
44            for g in i.groups:
45                print("%u" %g),
46            print
47