rz-pipe
| (require rz-pipe) | package: rz-pipe-lib |
This package provides a scripting interface for the Rizin Reverse Engineering Framework that builds upon Rizin’s command interface as a simple point of interaction.
While this library itself is written in Typed Racket, it can also be used in untyped Racket with contracts evaluated at runtime.
1 Examples
Scripting:
#lang racket (require (prefix-in rz: rz-pipe)) (define rz (rz:open "/bin/ls")) (printf "~v\n" (rz:cmd rz "ao @ main")) ; string result (printf "~v\n" (rz:cmdj rz "aoj @ main")) ; json result (rz:close rz)
Inside a live Rizin session:
$ rizin crackme0x00b |
[0x080483e0]> #!pipe racket |
Welcome to Racket v9.3 [cs]. |
> (require rz-pipe) |
> (cmdj (open) "pdj 1") |
'(#hasheq((bytes . "31ed") |
(comment . "WzEyXSAtci14IHNlY3Rpb24gc2l6ZSA0NjAgbmFtZWQgLnRleHQ=") |
(disasm . "xor ebp, ebp") |
(esil . "ebp,ebp,^=,$z,zf,:=,$p,pf,:=,31,$s,sf,:=,0,cf,:=,0,of,:=") |
(family . "cpu") |
(fcn_addr . 0) |
(fcn_last . 0) |
(flags . ("entry0" "section..text" "sym..text" "sym._start")) |
(offset . 134513632) |
(opcode . "xor ebp, ebp") |
(refptr . #f) |
(reloc . #f) |
(size . 2) |
(type . "xor") |
(type2_num . 0) |
(type_num . 28))) |
> |
2 Reference
type
procedure
filename : (U Bytes Path-String #f) = #f err-mode : (U 'forward 'ignore) = 'forward
If filename is given, a new Rizin instance is started as a subprocess and attached to. Pass "--" as filename if no file should be opened. In this mode, err-mode defines how to handle the subprocess’s stderr output:
'ignore hides stderr.
'forward copy-ports it into (current-error-port).
If filename is #f, open tries to attach to an existing Rizin session hosting the current Racket process. This is meant to be used when running under the #!pipe command inside Rizin itself.
Raises:
Raises exn:fail:rz-pipe:unexpected-data if Rizin closed its output before the result of command was fully received, for example because the Rizin process has exited.
Raises exn:fail:read if the output of command is not valid JSON.
struct
struct
struct