Home

Awesome

radare2 API bindings

This repository contains the native bindings generated with Valabind to use the radare2 APIs.

If you are looking for the r2pipe bindings, check this repository.

Description

This directory contains the code necessary to use the r2 api from your favourite language.

Supported target languages:

And some other experimental bindings are for:

This package also contains the vdoc/ subdirectory which contains the rules used to generate all interactive html documentation.

Dependencies

To build radare2-bindings from repository you need the following programs installed:

Release tarballs come with all the pregenerated .cxx files, so you have no extra dependencies apart from the language libraries and C++ compiler.

Using r2pm

Fortunely, all those dependencies can be installed with r2pm:

r2pm -cgi vala swig valabind

Source build

To get install all dependencies do the following steps in order:

arch$ sudo pacman -S swig valac
deb$ sudo apt install -y swig valac
mac$ brew install swig valac

Or install

$ git clone https://github.com/radare/valabind
$ cd valabind
$ make
$ sudo make install PREFIX=/usr

radare2-bindings

If you compile from the repo you need the latest version of valabind and then:

./configure --prefix=/usr

You can select the languages you want to compile with --enable={list-of-langs}

./configure --prefix=/usr --enable=python
make

r2libr (python)

r2libr are the most complete python bindings generated from source with all libr dynamic libraries bundled in a wheel.

You may have a try without the need to install radare2:

pip3 install --upgrade r2libr

For details, see r2libr.

Experimental radare2 bindgen

Introduction

This script allows to generate native bindings for these languages directly from radare2 C headers:

More languages are planned, in particular:

Usage

genbind.py -o /tmp/r2bindings-output

The tool required radare2 to be installed and takes the include directory from the output of r2 -H It is possible also specify the particular languages, for example:

genbind.py -o /tmp/r2bindings-output -l go rust python

PYTHON

To select the version of python to compile for use the PYTHON_CONFIG environment variable as follows:

$ ./configure --prefix=/usr --enable-devel
$ cd python
$ PYTHON_CONFIG=python3.2-config make
$ su -
# PYTHON_CONFIG=python3.2-config make install

RANDOM NOTES

The valabind integration forces us to do some changes in the r2 API.

These api changes are for:

  foreach (var foo in binls.get_symbols ()) {
	print ("%s 0x%08"PFMT64x"\n", foo.name, foo.offset);
  }

SWIG is not complete, there are still so many bugs to fix and so many unimplemented stuff. Here's a list of the most anoying things of it: