package binsec
Install
dune-project
Dependency
Authors
-
AAdel Djoudi
-
BBenjamin Farinier
-
CChakib Foulani
-
DDorian Lesbre
-
FFrédéric Recoules
-
GGuillaume Girol
-
JJosselin Feist
-
LLesly-Ann Daniel
-
MMahmudul Faisal Al Ameen
-
MManh-Dung Nguyen
-
MMathéo Vergnolle
-
MMathilde Ollivier
-
MMatthieu Lemerre
-
NNicolas Bellec
-
OOlivier Nicole
-
RRichard Bonichon
-
RRobin David
-
SSébastien Bardin
-
SSoline Ducousso
-
TTa Thanh Dinh
-
YYaëlle Vinçont
-
YYanis Sellami
Maintainers
Sources
sha256=4cf70a0367fef6f33ee3165f05255914513ea0539b94ddfef0bd46fc9b42fa8a
sha512=cd67a5b7617f661a7786bef0c828ee55307cef5260dfecbb700a618be795d81b1ac49fc1a18c4904fd2eb8a182dc862b0159093028651e78e7dc743f5babf9e3
doc/binsec.sse/Binsec_sse/Types/index.html
Module Binsec_sse.Types
type status = Metrics.status = The reason a path execution ends (via Signal).
type 'path continuation = | Continue of ([ `All ], 'path) fiber(*Reroutes the execution to the given low-level instructions.
*)| Call of 'path -> 'path continuation * 'path continuation(*Call the given OCaml function. Then, when the function yields
*)Return, evaluates the given continuation.| Tail_call of 'path -> 'path continuation(*Call the given OCaml function without altering the callstack.
*)| Return| Return_to of ([ `All ], 'path) fiber| Signal of status(*Ends the path execution.
If the status is
*)Stashed, the excecution can be resumed with the functionENGINE.resumeor aMergerequest.| Fork of 'path continuation * 'path continuation(*Request for a path fork. The parent path will evaluate the first continuation while the child path will evaluate the second one.
*)| Merge of 'path list * 'path continuation
The return of a Ir.builtin Call.
and (_, 'path) fiber = | Step : {addr : Binsec_kernel.Virtual_address.t;n : int;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Step | `All ], 'path) fiber| Assign : {var : Binsec_kernel.Dba.Var.t;rval : Binsec_kernel.Dba.Expr.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Assign | `All ], 'path) fiber| Clobber : {var : Binsec_kernel.Dba.Var.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Clobber | `All ], 'path) fiber| Load : {var : Binsec_kernel.Dba.Var.t;base : string option;dir : Binsec_kernel.Machine.endianness;addr : Binsec_kernel.Dba.Expr.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Load | `All ], 'path) fiber| Store : {base : string option;dir : Binsec_kernel.Machine.endianness;addr : Binsec_kernel.Dba.Expr.t;rval : Binsec_kernel.Dba.Expr.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Store | `All ], 'path) fiber| Symbolize : {var : Binsec_kernel.Dba.Var.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Symbolize | `All ], 'path) fiber| Apply : {f : 'path -> unit;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Apply | `All ], 'path) fiber| Assume : {test : Binsec_kernel.Dba.Expr.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Assume | `All ], 'path) fiber| Assert : {test : Binsec_kernel.Dba.Expr.t;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Assert | `All ], 'path) fiber| Branch : {test : Binsec_kernel.Dba.Expr.t;mutable taken : ([ `All ], 'path) fiber;mutable fallthrough : ([ `All ], 'path) fiber;
} -> ([< `Branch | `All ], 'path) fiber| Goto : Binsec_kernel.Virtual_address.t -> ([< `Goto | `All ], 'path) fiber| Jump : Binsec_kernel.Dba.Expr.t -> ([< `Jump | `All ], 'path) fiber| Call : {f : 'path -> 'path continuation;mutable succ : ([ `All ], 'path) fiber;
} -> ([< `Call | `All ], 'path) fiber| Tail_call : ('path -> 'path continuation) -> ([< `Tail_call | `All ], 'path) fiber
module type STATE = Binsec_sse.Symbolic.State.Smodule type PATH = Binsec_sse.Symbolic.Path.Stype 'a hook = {scope : Binsec_kernel.Virtual_address.t Binsec_kernel.Interval.t option;stage : stage;callback : 'a;
}A hook declaration as used by the extensions.
The hooks are evaluated in the following phase order: Fetch_hook, Decode_hook, Disasm_hook and Rewrite_hook.
Within the same phase, Early stage hooks are evaluated before Late stage hooks.
Within the same stage, hooks are evaluated in the order of insertion.
A hook is only active under a given scope (i.e range of addresses or None for always).
Return value of the Builtin_resolver callback.
type 'path extension = | Initialization_callback of 'path -> unit(*Registers the function
fto be called during initialization of the firstpath.It can be used to set the initial value of some
Dbavariables in the state or initialize some fields in thepathstructure.The function
*)fis called only once and before any instruction in the script.| Fetch_hook of (Binsec_kernel.Virtual_address.t -> Binsec_sse.Ir.Graph.t option) hook(*Registers the
hookhto be called each time a new virtual address in thescopeis discovered.Given the virtual address, the
callbackcan return a new instruction graph (Ir.Graph.t) to hook this address.If the graph ends with the
Ir.EndOfHookbuiltin, the disassembly continues to proceed with the following hooks. Otherwise, the hook acts as a replacement and skips the subsequent ones.The hooks of the same stage are evaluated in the same order they are inserted.
*)| Decode_hook of (Binsec_kernel.Virtual_address.t -> int Binsec_kernel.Reader.t -> Binsec_sse.Ir.Graph.t option) hook(*Registers the
hookhto be called each time a new virtual address in thescopeis about to be decoded (after all fetch hooks).Given the virtual address and the byte opcode (
Reader.t), thecallbackcan return a new instruction graph (Ir.Graph.t) to hook this address.If the graph ends with the
Ir.EndOfHookbuiltin, the disassembly continues to proceed with the following hooks. Otherwise, the hook acts as a replacement and skips the subsequent ones.The hooks of the same stage are evaluated in the same order they are inserted.
*)| Disasm_hook of (Binsec_kernel.Instruction.t -> Binsec_sse.Ir.Graph.t option) hook(*Registers the
hookhto be called each time a new virtual address in thescopehas been decoded (after all decode hooks).Given the decoded instruction (
Instruction.t), thecallbackcan return a new instruction graph (Ir.Graph.t) to hook this address.If the graph ends with the
Ir.EndOfHookbuiltin, the disassembly continues to proceed with the following hooks. Otherwise, the hook acts as a replacement and skips the subsequent ones.The hooks of the same stage are evaluated in the same order they are inserted.
*)| Rewrite_hook of (Binsec_sse.Ir.Graph.t -> unit) hook(*Registers the
hookhto be called each time a new virtual address in thescopeis about to yield a instruction graph (Ir.Graph.t) (after all disasm hooks).Given the instruction graph, the
callbackcan modify it in place using theIr.Graphinterface (e.g.Ir.Graph.insert_before,Ir.Graph.insert_list_before,Ir.Graph.replace_nodeorIr.Graph.append_node).The hooks of the same stage are evaluated in the same order they are inserted.
*)| Instrumentation_routine of Revision.t -> unit(*Registers the funcion
fto instrument the intermediate representation (Ir).It can be used to automatically insert new micro-instructions, including custom
Ir.builtins at strategic points (e.g. memory access, branch conditions, etc.).The function
fis called each time the engine discover new assembly instructions. The functionfcan explore the new micro-instructions by using theRevisioninterface. It can add new micro-instructions with the functionsRevision.insert_beforeandRevision.insert_list_before.The function should only modify the newly disassembled part of the graph (
Revision.is_new_vertex,Revision.iter_new_vertex). Inserting instructions in a previously visited part will raiseInvalid_argument.The function should not insert instructions before an
*)Ir.opcode.Instructionlabel. To instrument theIr.opcode.Instructionlabels, use theRevision.insert_beforeorRevision.insert_list_beforefunction on the successor of the node.| Grammar_extension of (unit, Binsec_script.obj, unit, unit, Binsec_script.obj Dyp.dyplexbuf) Dyp.dyp_action list(*A list of dypgen grammar rules (
*)Dyp.dyp_action).| Instruction_resolver of Binsec_sse.Script.Ast.Instr.t -> Script.env -> Ir.fallthrough list(*Registers the handler
fto translate custom script instructions (Script.Ast.Instr.t) to one or several micro-instruction (Ir.fallthrough), including customIr.builtins.The handler
fcan use the parser environment (Script.env) to parse and resolve script expressions withScript.eval_locandScript.eval_expr.The handler
*)fshould return a non empty instructionlistfor the script instructions it supports,[]otherwise.| Instruction_printer of Format.formatter -> Binsec_sse.Script.Ast.Instr.t -> bool(*Registers the custom printer
fto format the new script instruction (Script.Ast.Instr.t) in debug outputs.The printer
*)fshould returntruefor the instructions it handles,falseotherwise.| Command_handler of Binsec_sse.Script.Ast.t -> Script.env -> 'path -> bool(*Registers the handler
fto perform custom top level script commands (Script.Ast.t).The handler
fcan use the parser environment (Script.env) to parse and resolve script expressions withScript.eval_locandScript.eval_expr.The handler
*)fshould returntruewhen the command has been treated,falseotherwise.| Command_printer of Format.formatter -> Binsec_sse.Script.Ast.t -> bool(*Registers the custom printer
fto format the new top level script commands (Script.Ast.t) in debug outputs.The printer
*)fshould returntruefor the instructions it handles,falseotherwise.| Builtin_resolver of Ir.builtin -> 'path primitive(*Registers the function
fin charge to resolve the handler of a givenIr.builtin.The resolver
fshould returnCallhorApplyhfor thebuiltins it supports,Unknownotherwise. It is called once perbuiltinoccurrence in the intermediate representation (Ir).It is an error to not handle a
builtinadded by the plugin.The handler
hhas access to thepathinterface (PATH).It should return
Returnto resume the exploration along this path.Signalstatuscuts the path and logs the given status.The handler
*)his called each time the path reaches the givenIr.builtin.| Builtin_may_read of Ir.builtin -> Binsec_kernel.Dba_types.Var.Set.t option option(*Registers the knowledge provider
ffor customIr.builtins.It must return
Some kfor thebuiltinit handles,Noneotherwise.k = Some setis the (overapproximated) set of all variables the builtin may access. It is an error to access a variable not listed here and may result in undefined value.k = Nonemeans any variable may be accessed.
| Builtin_may_write of Ir.builtin -> Binsec_kernel.Dba_types.Var.Set.t option option(*Registers the knowledge provider
ffor customIr.builtins.It must return
Some kfor thebuiltinit handles,Noneotherwise.k = Some setis the (overapproximated) set of all variables the builtin may modify. It is an error to modify a variable not listed here and may result in undefined value.k = Nonemeans any variable may be modified.
| Builtin_must_write of Ir.builtin -> Binsec_kernel.Dba_types.Var.Set.t option(*Registers the knowledge provider
ffor customIr.builtins.It must return
*)Some setfor thebuiltinit handles,Noneotherwise.setis the (underapproximated) set of the variables a builtin must overwrite. Previous values of these variables are deemed no longer reachable.| Builtin_printer of Format.formatter -> Ir.builtin -> bool(*Registers the custom printer
fto format the customIr.builtins in debug outputs.The printer
*)fshould returntruewhen theIr.builtinis treated,falseotherwise.| Fork_callback of 'path -> 'path -> unit(*Registers the function
fto be called when a path execution is about to fork.It can be used to maintain invariants between the parent (first parameter) and the child (second parameter) paths.
*)| Signal_callback of 'path -> status -> unit(*Registers the function
*)fto be called when a path receives a signal. Thestatusgives information about why the execution is interrupted.| Exit_callback of unit -> unit(*Registers the function
fto be called when the exploration is about to terminate.It can be used to output some global wise statistics or results.
*)
An identifier used to declare new field in the PATH structure via the PLUGIN interface.
A PATH.key to a value of type 'a can be queried with the function ENGINE.lookup if the related field is present in one PLUGIN.fields list. The type 'a can be anything, including a function, and may depend on the type parameters 'value, 'model, 'state and 'path.
For instance, the field PATH.models could have been added as follows.
type ('value, 'model, 'state, 'path, 'a) field_id +=
| Models : ('value, 'model, 'state, 'path, 'model list) field_id
let fields _ =
[
Field
{
id = Models;
default = [];
copy = None;
merge = Some (fun x y -> Some (List.append x y));
};
]A field declaration used to declare new field in the PATH structure via the PLUGIN.fields list.
The declaration contain an identifier id (field_id), the default value, an optional copy function and an optional merge function.
The copy function is called each time a path is forked to create a new local copy of the field value (by default Fun.id).
The merge function is called each time two paths are about to merge. It returns Some when the field values are mergeable, and None otherwise (by default, it returns Some if both values are physically equal).
module type ENGINE = sig ... endmodule type PLUGIN = sig ... endmodule type EXTENSIONS = sig ... end