Skip to content

anio/capstone.js

 
 

Repository files navigation

Capstone.js

Last Release

Port of the Capstone disassembler framework for JavaScript. Powered by Emscripten.

Notes: Capstone is a lightweight multi-architecture disassembly framework originally developed by Nguyen Anh Quynh and released under BSD license. More information about contributors and license terms can be found in the files CREDITS.TXT and LICENSE.TXT of the capstone submodule in this repository.

Installation

To install the Capstone.js install in your web application, include it with:

<script src="capstone.min.js"></script>

or installer through the Bower command:

bower install capstonejs

Usage

// Input: Machine code bytes and offset where they are located
var buffer = [0x55, 0x48, 0x8b, 0x05, 0xb8, 0x13, 0x00, 0x00];
var offset = 0x1000;

// Initialize the decoder
var cs = new capstone.Cs(capstone.ARCH_X86, capstone.MODE_64);

// Output: Array of capstone.Instruction objects
var instructions = cs.disasm(buffer, offset);

// Display results;
instructions.forEach(function (instr) {
    console.log("0x%s:\t%s\t%s",
        instr.address.toString(16),
        instr.mnemonic,
        instr.op_str
    );
});

// Delete decoder
cs.delete();

Building

To build the Capstone.js library, clone the master branch of this repository, and do the following:

  1. Initialize the original Capstone submodule: git submodule update --init.

  2. Install the development and client dependencies with: npm install and bower install.

  3. Install the lastest Python 2.x (64-bit), CMake and the Emscripten SDK. Follow the respective instructions and make sure all environment variables are configured correctly. Under Windows MinGW (specifically mingw32-make) is required.

  4. Finally, build the source with: grunt build.

About

Capstone disassembler framework for JavaScript

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 80.0%
  • JavaScript 16.7%
  • Python 3.3%