package binsec

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type kind =
  1. | Fallthrough
    (*

    The instruction jumps to its immediate follower.

    *)
  2. | Branch
    (*

    The instruction branchs to another one.

    *)
  3. | Call
    (*

    The instruction calls a function.

    *)
  4. | Return of Virtual_address.t
    (*

    The instruction returns to the caller.

    *)
  5. | Presumed
    (*

    The instruction calls a function that may not return properly. Its immediate follower is taken as successor.

    *)
include Graph.Sig.I with type V.t = Binsec.Virtual_address.t and type E.t = Binsec.Virtual_address.t * kind * Binsec.Virtual_address.t
type t
module V : sig ... end
type vertex = V.t
module E : sig ... end
type edge = E.t
val is_directed : bool
val is_empty : t -> bool
val nb_vertex : t -> int
val nb_edges : t -> int
val out_degree : t -> vertex -> int
val in_degree : t -> vertex -> int
val mem_vertex : t -> vertex -> bool
val mem_edge : t -> vertex -> vertex -> bool
val mem_edge_e : t -> edge -> bool
val find_edge : t -> vertex -> vertex -> edge
val find_all_edges : t -> vertex -> vertex -> edge list
val succ : t -> vertex -> vertex list
val pred : t -> vertex -> vertex list
val succ_e : t -> vertex -> edge list
val pred_e : t -> vertex -> edge list
val iter_vertex : (vertex -> unit) -> t -> unit
val fold_vertex : (vertex -> 'a -> 'a) -> t -> 'a -> 'a
val iter_edges : (vertex -> vertex -> unit) -> t -> unit
val fold_edges : (vertex -> vertex -> 'a -> 'a) -> t -> 'a -> 'a
val iter_edges_e : (edge -> unit) -> t -> unit
val fold_edges_e : (edge -> 'a -> 'a) -> t -> 'a -> 'a
val map_vertex : (vertex -> vertex) -> t -> t
val iter_succ : (vertex -> unit) -> t -> vertex -> unit
val iter_pred : (vertex -> unit) -> t -> vertex -> unit
val fold_succ : (vertex -> 'a -> 'a) -> t -> vertex -> 'a -> 'a
val fold_pred : (vertex -> 'a -> 'a) -> t -> vertex -> 'a -> 'a
val iter_succ_e : (edge -> unit) -> t -> vertex -> unit
val fold_succ_e : (edge -> 'a -> 'a) -> t -> vertex -> 'a -> 'a
val iter_pred_e : (edge -> unit) -> t -> vertex -> unit
val fold_pred_e : (edge -> 'a -> 'a) -> t -> vertex -> 'a -> 'a
val create : ?size:int -> unit -> t
val clear : t -> unit
val copy : t -> t
val add_vertex : t -> vertex -> unit
val remove_vertex : t -> vertex -> unit
val add_edge : t -> vertex -> vertex -> unit
val add_edge_e : t -> edge -> unit
val remove_edge : t -> vertex -> vertex -> unit
val remove_edge_e : t -> edge -> unit
val parse_cache : path:string -> t * string Virtual_address.Htbl.t

parse_cache ~path build a new graph from the saved textual output of a previously Ghidra run.

  • parameter path

    The path of the Ghidra log.

  • returns

    A new imperative graph with its mnemonic mapping.

val run_ghidra : ?temp_dir:string -> ?cache:string -> runner:string -> string -> t * string Virtual_address.Htbl.t

run_ghidra ?cache ~runner binary run Ghidra disassembly on the binary file and extract its control flow graph.

  • parameter temp_dir

    The path of the workspace in which Ghidra will be run (default is /dev/shm).

  • parameter cache

    If any, save in this file the textual output of Ghidra for later use.

  • parameter runner

    The path of the the analyzeHeadless Ghidra script.

  • parameter binary

    The path of the binary under study.

  • returns

    A new imperative graph with its mnemonic mapping.

val import : unit -> t * string Virtual_address.Htbl.t

import () calls run_ghidra or parse_cache on the executatble file (Kernel_options.ExecFile) according to the global options Ghidra_options.Runner and Ghidra_options.Cache.

  • returns

    A new imperative graph with its mnemonic mapping.

OCaml

Innovation. Community. Security.