61  Rz-pipe

The rz-pipe module permits interacting with rizin instances in different methods:

         pipe spawn async http tcp rap json
python    x     x     -    x    x    x   x
haskell   x     x     -    x    -    -   x
ocaml     x     x     -    x    -    -   x
rust      x     x     x    x    -    -   x

62 Examples

62.1 Python

$ pip install rzpipe
import rzpipe

rz = rzpipe.open("/bin/ls")
rz.cmd('aa')
print(rz.cmd("afl"))
print(rz.cmdj("aflj"))  # evaluates JSONs and returns an object

62.2 Haskell

import RzPipe
import qualified Data.ByteString.Lazy as L

showMainFunction ctx = do
  cmd ctx "s main"
  L.putStr =<< cmd ctx "pD `fl $$`"

main = do
  -- Run rizin locally
  open "/bin/ls" >>= showMainFunction
  -- Connect to rizin via HTTP (e.g. if "rizin -qc=h /bin/ls" is running)
  open "http://127.0.0.1:9090" >>= showMainFunction

62.3 OCaml

let result = Rz.with_command ~cmd:"/j chown" "/bin/ls"
Printf.printf "Rizin output is: %s" result

62.4 Rust

 #[macro_use]
 extern crate rzpipe;
 extern crate serde_json;
 use rzpipe::RzPipe;
 fn main() {
     let path = Some("/bin/ls".to_owned());
     let mut rzp = open_pipe!(path).unwrap();
     println!("{}", rzp.cmd("?e Hello World").unwrap());
     if let Ok(json) = rzp.cmdj("ij") {
         println!("{}", serde_json::to_string_pretty(&json).unwrap());
         println!("ARCH {}", json["bin"]["arch"]);
     }
     rzp.close();
 }

62.5 Ruby

require './rzpipe'

begin
  rzp = RzPipe.new
rescue Exception => e
  rzp = RzPipe.new '/bin/ls'
end
  puts rzp.cmd 'a'
  puts rzp.cmd 'pd 10 main'
  rzp.quit