jueves, 7 de agosto de 2014

[HowTo] Install Radare2 with bindings

Original title was:  How to install Radare2 with bindings and not to die in the intent xD

I will not tell you what is R2, because if you read it, you know what is it. Is an awesome tool for RE.

I only will leave here some of pages related with this tool, so if you are interested in learn more about Radare2 you can do it in next pages:

Installation was do in Debian like system, in other arch you can use the same tricks I think ;)

$ git clone https://github.com/radare/radare2.git
$ cd radare2
$ ./sys/install.sh

$ sudo apt-get update  
$ sudo apt-get install -y software-properties-common python-all-dev wget build-essential autogen autoconf 
$ sudo apt-get install -y swig flex bison git gcc g++ make pkg-config 
$ sudo apt-get install -y  gobject-introspection python-gobject-dev glib-2.0 libglib2.0-dev node-gyp
Compile vala
wget http://download.gnome.org/sources/vala/0.24/vala-0.24.0.tar.xz; tar -Jxf vala-0.24.0.tar.xz 

vala-0.24.0; ./configure --prefix=/usr ; make && sudo make install ; cd ..

git clone git://git.gnome.org/vala && cd vala && sh autogen.sh --prefix=/usr && make && sudo make install; cd ..
Compile ctypes
cd radare2-bindings/ctypes; make; cd ..
Installing valabind, not install it with apt-get, because you will get old version, you can check version of package using apt-cache show valabind, if is < 0.8 download it from official repo.

Debian package can be found here

Ubuntu package can be found here

cd radare2; ./sys/all.sh; cd ..
Installing bindings First, get your python dist-package dir, for this you can do the next:
Fast way to get install dir is using command
locate dist-packages

or
cd radare2-bindigs; vim Makefile 
after install-ctypes(in current github version is line 164) is add: echo ${PYTHON_INSTALL_DIR}

In my case is /usr/lib/python2.7/dist-packages/r2
Now change user to root and copy the libs to python install dir
sudo su

If your path is different, you will need adjust all path in next block
mkdir -p /usr/lib/python2.7/dist-packages/r2

echo "Installing python2.7 r2 modules in /usr/lib/python2.7/dist-packages/" ; mkdir -p /usr/lib/python2.7/dist-packages/r2 ; : > /usr/lib/python2.7/dist-packages/r2/__init__.py ; cp -rf ctypes/r_*.py /usr/lib/python2.7/dist-packages/r2/; exit
Cleaning
 
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Sources:
radare.today
Radare and Radare bindings README.md files

Special thanks to @pancake :)