Access radare2 via pipe from any programming language!
JavaScript Python C# HTML Swift Makefile Other
Clone or download
Latest commit d388f2b Jul 17, 2018
Permalink
Failed to load latest commit information.
c Fix compilation and run of r2pipe-c for gcc on linux Apr 6, 2017
clojure Adds r2pipe.clj (Clojure) code Oct 13, 2016
cxx-qt Add r2pipe-qt naked native API support Nov 24, 2016
dlang Fix #r2pipe #dlang Oct 24, 2015
dotnet Add support for .NET Core Oct 18, 2016
erlang Enhanced ORIGIN sync and add make dist Oct 7, 2016
go r2pipe.go now have a makefile to properly sync with master repo Nov 22, 2017
haskell Add example file demonstrating how to use the haskell r2pipe bindings… Jun 26, 2015
java Parametrize the r2 path for Java Nov 8, 2016
lisp add r2pipe lisp bindings for radare2. Oct 3, 2015
newlisp Implement spawn method for newlisp Dec 13, 2016
nim Add JSON support for Nim Oct 19, 2016
nodejs Release r2pipe.js 2.6.3 Jul 17, 2018
ocaml Remove abandoned OCaml r2pipe, update maintained one (#56) Apr 8, 2018
perl Perl r2pipe empty json fix + improved documentation (#18) Mar 31, 2017
php Initial PoC implementation of r2pipe.php Oct 7, 2016
python-async add: new async API for Python 3. Without external dependencies Jul 5, 2016
python Now MANIFEST.in includes itself (#59) Apr 28, 2018
r2core-js Add pako.js to uncompress r2core.js in client side Feb 5, 2017
ruby Use raise Nov 6, 2017
rust Sync go, rust and ocaml Jun 12, 2017
swift Almost fully convert r2pipe.swift for Swift4 Jun 26, 2017
vala build with performance and debugging symbols May 24, 2016
.gitignore Refactor syntax Mar 5, 2018
Makefile Release 2.7.0 Jul 9, 2018
README.md Implement spawn method for newlisp Dec 13, 2016
r2pipe.png Update README Oct 7, 2016

README.md

r2pipe

r2pipe logo

The r2pipe APIs are based on a single r2 primitive found behind r_core_cmd_str() which is a function that accepts a string parameter describing the r2 command to run and returns a string with the result.

The decision behind this design comes from a series of benchmarks with different libffi implementations and resulted that using the native API is more complex and slower than just using raw command strings and parsing the output.

As long as the output can be tricky to parse, it's recommended to use the JSON output and deserializing them into native language objects which results much more handy than handling and maintaining internal data structures and pointers.

Also, memory management results into a much simpler thing because you only have to care about freeing the resulting string.

This directory contains different implementations of the r2pipe API for different languages which could handle different communication backends:

  • Grab R2PIPE{_IN|_OUT} environment variables
  • Spawn r2 -q0 and communicate with pipe(2)
  • Plain TCP connection
  • HTTP queries (connecting to a remote webserver)
  • RAP protocol (r2 own's remote protocol)

Most of the language enable asyncronous capabilities in order to handle the result of the operation in a callback, allowing a single program to interact with multiple instances or connections to different r2 sessions at the same time.

  • Syncronous
  • Asyncronous

In addition, r2pipe scripts can be used to write plugins for radare2 or extend current functionalities:

  • Assembler/Disassembler plugin for RAsm
  • RIO plugin to abstract read/write/system operations
  • Syscall handler for the ESIL emulator
  • ...

The most supported languages are:

  • NodeJS
  • Python
  • Swift
  • C/Nim/Vala/C++

But there is r2pipe for:

          pipe spawn async http tcp rap json plug lib buff
C           X     X     -    X    X   X    X    X   X   X
C++/Qt      X     X     -    -    -   -    X    -   X   -
C# / F#     X     X     X    X    -   -    -    -   X   -
D           X     -     -    -    -   -    X    -   -   -
Erlang      X     X     -    -    -   -    -    -   -   -
Go          X     X     -    -    -   -    X    -   -   -
Haskell     X     X     -    X    -   -    X    -   -   -
Java/Groovy -     X     -    X    -   -    -    -   X   -
Lisp        -     X     -    -    -   -    X    -   -   -
NewLisp     X     X     -    X    -   -    X    -   X   -
Nim         -     -     -    X    -   -    X    -   X   -
NodeJS      X     X     X    X    X   -    X    X   -   X
Ocaml       -     X     -    -    -   -    X    -   -   -
Perl        X     X     -    X    X   -    X    -   -   -
PHP         -     X     -    -    -   -    -    -   -   -
Python      X     X     X    X    X   X    X    X   X   -
Ruby        X     X     -    -    -   -    X    -   -   -
Rust        X     X     -    -    -   -    X    -   -   -
Swift       X     X     X    X    -   -    X    -   X   -
Vala        -     X     X    -    -   -    -    -   -   -
Clojure     X     X     -    -    -   -    -    -   -   -

--pancake