Skip to content

CzBiX/disasm-web

Repository files navigation

disasm-web

npm npm

Online Assembler and Disassembler.

This project ported capstone and keystone into the browser via emscripten.

Playground: https://disasm.czbix.com/ (support offline usage)

NPM packages

There are two packages available: capstone-wasm and keystone-wasm.

Usage

import {
  Const, Capstone, loadCapstone,
} from 'capstone-wasm'

await loadCapstone()

const capstone = new Capstone(Const.CS_ARCH_X86, Const.CS_MODE_32)
// the code can be bytes array or Uint8Array
const code = [0x55, 0x8b, 0xec, 0x83, 0xc4, 0x0c, 0xc3]
const insns = capstone.disasm(code, {
  address: 0x1000,
})

insns.forEach(insn => {
  console.log(insn.mnemonic, insn.opStr)
})
import {
  Const, Keystone, loadKeystone,
} from 'keystone-wasm'

await loadKeystone()

const capstone = new Keystone(Const.KS_ARCH_X86, Const.KS_MODE_32)
// can separate code by `\n` or `;`
const code = `push ebp
mov ebp, esp
add esp, 0xc
ret`
// bytes is a Uint8Array
const bytes = keystone.asm(code, {
  address: 0x1000,
})

Cons

Not support detail feature(CS_OPT_DETAIL) yet.