Skip to content

aziem/binaryninja-ocaml

Repository files navigation

README

About

OCaml API for Binary Ninja : Only tested on Linux.

Current status: low level bindings track the master branch of Binary Ninja API repo.

Higher level bindings are currently in progress (under the lib directory)

Building

Requires Oasis for build system (for now) and of-course a copy of Binary Ninja, and the binaryninja-api repository (master branch).

Note that you need a commercial version (not the personal version) to be able to run plugins in headless mode.

  1. First set some variables: in config.ml set the location of the binaryninjacore.h file (which is part of the Binary Ninja API)
  2. In myocamlbuild.ml change the variable binaryninja_lib_loc to point to directory containing your Binary Ninja installation.
  3. Run oasis setup, then make.

    Building takes a few minutes due to large OCaml modules containing the bindings.

    TODO: fix this by splitting the bindings into smaller modules.

  4. Run make install

Example Plugins

The examples directory contains some sample plugins. Each plugin is installed into the Binary Ninja plugins directory (~/.binaryninja/plugins)

Plugins: breakpoint: port of the Python plugin to set a breakpoint

iterfuncnames: plugin which logs the list of functions in the binary

walk-dfs: depth first walk over the control flow graph, printing some info.

Each plugin is built by creating a C file to allow Binary Ninja to load the plugin via CoreInitPlugin: this C file calls into the plugin to actually do the work.

The module in GeneratePlugin generates the C file and also registers the OCaml callback.

(Note to self: this is a bit of a hack, I tried using ocaml-ctypes-inverted to generate the C but this raised exceptions, so using the Callback.register method for now)

Building

Go to a plugin directory. First we need to set the LD_LIBRARY_PATH variable to point to the Binary Ninja installation. Once this is done, run make and then make install. This will install the plugin in the default plugin directory: ~/.binaryninja/plugins

About

OCaml bindings to Binary Ninja

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published