rz-pipe: Pipe interface for Rizin

[ library, mit, program, reverse-engineering, security ] [ Propose Tags ]

rz-pipe is a scripting interface for the Rizin Reverse Engineering Framework that builds upon Rizin's command interface as a simple point of interaction.

It can be used by launching a Rizin instance from Haskell or connecting to an existing one using pipes or HTTP.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0
Change log CHANGELOG.md
Dependencies aeson (>=1.5.5 && <1.6), base (>=4.12 && <5), bytestring (>=0.10.12 && <0.11), HTTP (>=4000.3.15 && <4000.4), process (>=1.6.9 && <1.7), rz-pipe, utf8-string (>=1.0.2 && <1.1) [details]
License MIT
Author rizinorg
Maintainer Florian Märkl <rizin@metallic.software>
Category Reverse Engineering, Security
Uploaded by FlorianMaerkl at 2021-01-20T13:12:39Z
Distributions
Executables example
Downloads 162 total (10 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-01-20 [all 1 reports]

Readme for rz-pipe-0.1.0

[back to package description]

rz-pipe for Haskell

rz-pipe is a scripting interface for the Rizin Reverse Engineering Framework that builds upon Rizin's command interface as a simple point of interaction.

It can be used by launching a Rizin instance from Haskell or connecting to an existing one using pipes or HTTP.

Usage

The API revolves around the RzContext type, which represents a connection to a running Rizin instance. The open function will establish such a connection in IO based on its argument:

do
  -- Spawn a new rizin instance and open the /bin/ls binary in it
  localCtx <- open $ Just "/bin/ls"
  -- Pick up pipes from parent rizin process
  parentCtx <- open Nothing
  -- Connect to rizin via HTTP (e.g. if "rizin -qc=h /bin/ls" is running)
  httpCtx <- open $ Just "http://127.0.0.1:9090"

Once a context has been opened, the cmd function can be used to run commands and return the result as a string in IO:

putStrLn =<< cmd ctx "pd 3"
-- prints e.g.
--   0x00005b20      endbr64
--   0x00005b24      xor   ebp, ebp
--   0x00005b26      mov   r9, rdx

For scripting, it is highly recommended to use rizin commands returning json, commonly prefixed with j. To conveniently parse the results with aeson, the cmdj can be used, which is polymorphic in its return type and can produce any object in the Data.Aeson.FromJSON type class:

{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}

import RzPipe
import GHC.Generics
import Data.Aeson as JSON
import Data.Word

data Flag = Flag
    { name :: String
    , size :: Word64
    , offset :: Word64 }
    deriving (Show, Generic, JSON.FromJSON)

showFlags :: RzContext -> IO ()
showFlags ctx = print =<< (cmdj ctx "fj" :: IO (Maybe [Flag]))
-- prints e.g.
-- Just [Flag {name = "section.", size = 0, offset = 0},Flag {name = "section..comment", size = 76, offset = 0},Flag {name = "section..shstrtab", size = 247, offset = 0},Flag {name = "segment.LOAD0", size = 13584, offset = 0},Flag {name = "segment.GNU_STACK", size = 0, offset = 0},Flag {name = "segment.ehdr", size = 64, offset = 0} ...