13 from capstone
import *
16 from random
import randint
21 FILE =
'/usr/bin/python'
25 (CS_ARCH_X86, CS_MODE_16,
"X86-16 (Intel syntax)", 0),
26 (CS_ARCH_X86, CS_MODE_32,
"X86-32 (ATT syntax)", CS_OPT_SYNTAX_ATT),
27 (CS_ARCH_X86, CS_MODE_32,
"X86-32 (Intel syntax)", 0),
28 (CS_ARCH_X86, CS_MODE_64,
"X86-64 (Intel syntax)", 0),
29 (CS_ARCH_ARM, CS_MODE_ARM,
"ARM", 0),
30 (CS_ARCH_ARM, CS_MODE_THUMB,
"THUMB (ARM)", 0),
31 (CS_ARCH_MIPS, CS_MODE_MIPS32 + CS_MODE_BIG_ENDIAN,
"MIPS-32 (Big-endian)", 0),
32 (CS_ARCH_MIPS, CS_MODE_MIPS64 + CS_MODE_LITTLE_ENDIAN,
"MIPS-64-EL (Little-endian)", 0),
33 (CS_ARCH_ARM64, CS_MODE_ARM,
"ARM-64 (AArch64)", 0),
34 (CS_ARCH_PPC, CS_MODE_BIG_ENDIAN,
"PPC", 0),
35 (CS_ARCH_PPC, CS_MODE_BIG_ENDIAN,
"PPC, print register with number only", CS_OPT_SYNTAX_NOREGNAME),
36 (CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN,
"Sparc", 0),
37 (CS_ARCH_SYSZ, 0,
"SystemZ", 0),
38 (CS_ARCH_XCORE, 0,
"XCore", 0),
39 (CS_ARCH_M68K, 0,
"M68K", 0),
45 return " ".join(
"0x" +
"{0:x}".format(ord(c)).zfill(2)
for c
in s)
58 insns = md.disasm(code, 0)
62 if i.address == 0x100000:
67 insns = md.disasm_lite(code, 0)
68 for (addr, size, mnem, ops)
in insns:
75 for (arch, mode, comment, syntax)
in all_tests:
78 if not request
in comment.lower():
83 print(
"Platform: %s" %comment)
102 for i
in xrange(50000):
111 print "Benchmark - full obj:", c_t,
"seconds"
116 for i
in xrange(50000):
125 print "Benchmark - lite:", c_t,
"seconds"
128 print(
"ERROR: %s" %e)
static static fork const void static count static fd const char const char static newpath char char char static envp time