62 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)
Language | 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.1 Examples
62.1.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
62.1.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
62.1.3 OCaml
let result = Rz.with_command ~cmd:"/j chown" "/bin/ls"
Printf.printf "Rizin output is: %s" result
62.1.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}
62.1.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