• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    Go
  • License
    Other
  • Created almost 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gapstone is a Go binding for the capstone disassembly library

gapstone

RETIRED

This binding is no longer maintained. It has been forked at https://github.com/knightsc/gapstone

Thanks!

ben

OLD README FOLLOWS

Gapstone is a Go binding for the Capstone disassembly library.

CURRENT UPSTREAM VERSION: 4.0.1

Build Status

(head over to the next branch for the newest stuff)

SUMMARY

( FROM THE CAPSTONE README )

Capstone is a disassembly framework with the target of becoming the ultimate disasm engine for binary analysis and reversing in the security community.

Created by Nguyen Anh Quynh, then developed and maintained by a small community, Capstone offers some unparalleled features:

  • Support multiple hardware architectures: ARM, ARM64 (ARMv8), Mips, PPC, Sparc, SystemZ, XCore and X86.

  • Having clean/simple/lightweight/intuitive architecture-neutral API.

  • Provide details on disassembled instruction (called โ€œdecomposerโ€ by others).

  • Provide semantics of the disassembled instruction, such as list of implicit registers read & written.

  • Implemented in pure C language, with lightweight wrappers for C++, C#, Go, Java, NodeJS, Ocaml, Python, Ruby & Vala ready (available in main code, or provided externally by the community).

  • Native support for all popular platforms: Windows, Mac OSX, iOS, Android, Linux, *BSD, Solaris, etc.

  • Thread-safe by design.

  • Special support for embedding into firmware or OS kernel.

  • Distributed under the open source BSD license.

Further information is available at http://www.capstone-engine.org

To install:

First install the capstone library from either https://github.com/aquynh/capstone or http://www.capstone-engine.org

Then, assuming you have set up your Go environment according to the docs, just:

go get -u github.com/bnagy/gapstone

Tests are provided. You should probably run them.

cd $GOPATH/src/github.com/bnagy/gapstone
go test

To start writing code:

Take a look at the examples *_test.go

Here's "Hello World":

package main

import (
    "github.com/bnagy/gapstone"
    "log"
)

func main() {

    engine, err := gapstone.New(
        gapstone.CS_ARCH_X86,
        gapstone.CS_MODE_32,
    )

    if err == nil {

        defer engine.Close()

        maj, min := engine.Version()
        log.Printf("Hello Capstone! Version: %v.%v\n", maj, min)

        var x86Code32 = "\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34" +
            "\x12\x00\x00\x05\x23\x01\x00\x00\x36\x8b\x84\x91" +
            "\x23\x01\x00\x00\x41\x8d\x84\x39\x89\x67\x00\x00" +
            "\x8d\x87\x89\x67\x00\x00\xb4\xc6"

        insns, err := engine.Disasm(
            []byte(x86Code32), // code buffer
            0x10000,           // starting address
            0,                 // insns to disassemble, 0 for all
        )

        if err == nil {
            log.Printf("Disasm:\n")
            for _, insn := range insns {
                log.Printf("0x%x:\t%s\t\t%s\n", insn.Address, insn.Mnemonic, insn.OpStr)
            }
            return
        }
        log.Fatalf("Disassembly error: %v", err)
    }
    log.Fatalf("Failed to initialize engine: %v", err)
}

Autodoc is available at http://godoc.org/github.com/bnagy/gapstone

Contributing

If you feel like chipping in, especially with better tests or examples, fork and send me a pull req.

Library Author: Nguyen Anh Quynh
Binding Author: Ben Nagy
License: BSD style - see LICENSE file for details

(c) 2013 COSEINC. All Rights Reserved.

More Repositories

1

cgasm

We're insanely passionate about command line asm documentation in the cloud, and we're crushing it!
PLpgSQL
371
star
2

crashwalk

Bucket and triage on-disk crashes. OSX and Linux.
Go
349
star
3

afl-trivia

Short, unrelated helper scripts for users of AFL (the fuzzer)
Shell
110
star
4

afl-launch

Boring tool to launch multiple afl-fuzz instances
Go
49
star
5

crabstone

crabstone is a Ruby binding to the capstone disassembly library by Nguyen Anh Quynh
C#
40
star
6

francis

LLDB engine based tool to instrument OSX apps and triage crashes
Python
26
star
7

slides

Some slides from some presentations I have given
25
star
8

raf

Ruby ALPC Fuzzer ( joke )
Ruby
24
star
9

osx-afl-llvm

Barely working LLVM mode for AFL on OSX
C
20
star
10

rBuggery

Ruby wrapper for dbgeng.dll
C
17
star
11

terry

Wrap radamsa on OSX, add instrumentation / triage.
Go
15
star
12

enough

Just enough TLS sugar
Go
14
star
13

babysit

Run a windows process with many inputs and catch exit codes
Go
14
star
14

gootool

Silly PoC of a limited otool clone based on the capstone disassembly lib
Go
12
star
15

alpcgo

Go tools for basic ALPC hacking
Go
11
star
16

aflfix

Use any program to perform fixups for afl via AFL_POST_LIBRARY
Go
11
star
17

pdflex

Minimal and hacky PDF lexer
Go
10
star
18

alpcmap

Connect to a JSON rBuggery stub to map Windows ALPC information
Go
8
star
19

ruby-kernel

Assorted cut and paste fodder for messing with some syscall / USER / GDI stuff from Ruby.
Ruby
7
star
20

pdftok

Minimal and hacky PDF lexer
Go
6
star
21

bm2-server

Server components for Bugmine 2.0
Ruby
4
star
22

bm2-client

Client code for Bugmine 2.0 (only win32 so far)
Ruby
4
star
23

mqdq-parser

Utility scripts in python for working with XML poems from MQDQ
Python
4
star
24

bm2-core

Shared components for Bugmine 2.0
Ruby
4
star
25

nux-paper

Anxiety and Walnuts
Jupyter Notebook
4
star
26

fail-paper

Jupyter Notebook
3
star
27

rhyme-paper

Preprint: Rhyme in Latin poetry: Stylistic or Stochastic?
Jupyter Notebook
3
star
28

alpcbuggery

Wrapper for the ALPC interaction methods used by github.com/bnagy/alpcmap
Go
3
star
29

metronome

tracing variation in poetic metres via local sequence alignment
Jupyter Notebook
3
star
30

sfst-python

Minimal Python wrapper for the SFST morphological analysis tools
C++
2
star
31

hexml-paper

Preprint: Metre as a stylometric feature in Latin hexameter poetry
Jupyter Notebook
2
star
32

codeloops

Loops created from doubly even binary codes
TeX
2
star
33

ovvo

A project to investigate verb order change in Latin
Python
2
star
34

itunes-dedup

How I dedup my iTunes. Almost certainly dangerously broken.
Ruby
1
star
35

gobuggery

Lower level wrapper for the basic remote debugger connection to github.com/bnagy/rBuggery
Go
1
star