安装
pip install keystone-engine
pip install six
测试:
from keystone import *
# separate assembly instructions by ; or \n
CODE = b"INC ecx; DEC edx"
try:
# Initialize engine in X86-32bit mode
ks = Ks(KS_ARCH_X86, KS_MODE_32)
encoding, count = ks.asm(CODE)
print("%s = %s (number of statements: %u)" %(CODE, encoding, count))
except KsError as e:
print("ERROR: %s" %e)
输出:
b'INC ecx; DEC edx' = [65, 74] (number of statements: 2)