2019-02-20 23:32:34 +00:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
from capstone import Cs, CS_ARCH_X86, CS_MODE_64
|
|
|
|
import json
|
|
|
|
|
|
|
|
capstone = Cs(CS_ARCH_X86, CS_MODE_64)
|
|
|
|
|
2019-02-24 07:38:11 +00:00
|
|
|
|
|
|
|
def disasm(shellcode: bytes) -> list:
|
2019-02-20 23:32:34 +00:00
|
|
|
opcodes = list()
|
|
|
|
|
|
|
|
for opcode in capstone.disasm(shellcode, 0):
|
|
|
|
opcodes.append([opcode.mnemonic, opcode.op_str])
|
|
|
|
|
|
|
|
return opcodes
|
2019-02-24 06:18:46 +00:00
|
|
|
|
2019-02-24 07:38:11 +00:00
|
|
|
|
|
|
|
def objdump(shellcode: bytes) -> str:
|
2019-02-24 06:18:46 +00:00
|
|
|
opcodes = str()
|
|
|
|
|
|
|
|
for opcode in capstone.disasm(shellcode, 0):
|
2019-02-24 06:19:41 +00:00
|
|
|
opcodes += f'{opcode.mnemonic} {opcode.op_str}\n'
|
2019-02-24 06:18:46 +00:00
|
|
|
|
|
|
|
return opcodes
|