60 Rz-pipe
The rz-pipe module permits interacting with rizin instances in different methods:
- spawn pipes (rizin -0)
- http queries (cloud friendly)
- tcp socket (rizin -c)
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
61 Examples
61.1 Python
$ pip install rzpipe
import rzpipe
= rzpipe.open("/bin/ls")
rz 'aa')
rz.cmd(print(rz.cmd("afl"))
print(rz.cmdj("aflj")) # evaluates JSONs and returns an object
61.2 Haskell
import RzPipe
import qualified Data.ByteString.Lazy as L
= do
showMainFunction ctx "s main"
cmd ctx =<< cmd ctx "pD `fl $$`"
L.putStr
= do
main -- Run rizin locally
"/bin/ls" >>= showMainFunction
open -- Connect to rizin via HTTP (e.g. if "rizin -qc=h /bin/ls" is running)
"http://127.0.0.1:9090" >>= showMainFunction open
61.3 OCaml
let result = Rz.with_command ~cmd:"/j chown" "/bin/ls"
Printf.printf "Rizin output is: %s" result
61.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"]);
}
.close();
rzp}
61.5 Ruby
require './rzpipe'
begin
= RzPipe.new
rzp rescue Exception => e
= RzPipe.new '/bin/ls'
rzp end
puts rzp.cmd 'a'
puts rzp.cmd 'pd 10 main'
.quit rzp