scrap-is-not-scrap/sins/disassemble.py

22 lines
496 B
Python
Raw Normal View History

#! /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 06:18:46 +00:00
def disasm(shellcode: bytes)->list:
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
def objdump(shellcode: bytes)->str:
opcodes = str()
for opcode in capstone.disasm(shellcode, 0):
opcodes += f'{opcode.mnemonic} {opcode.op_str}'
return opcodes