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/Interpreter/Concrete/argument-1-P/index.html
Parameter Concrete.P
val id : t -> intid p returns the unique identifier of the path p.
val pc : t -> Binsec_kernel.Virtual_address.taddr p returns the current program counter of the path p.
State update
val symbolize : t -> Binsec_kernel.Dba.Var.t -> unitsymbolize p v assigns the variable v with a new symbolic value.
Each call to symbolize records the new value on top of the symbols history.
val assign : t -> Binsec_kernel.Dba.Var.t -> Binsec_kernel.Dba.Expr.t -> unitassign p v e assigns the variable v with the expression e.
val clobber : t -> Binsec_kernel.Dba.Var.t -> unitassign p v e assigns the variable v with a new symbolic value.
Clobbered variables are expected to not be used by the program and are not recorded in the symbols history.
val load :
t ->
Binsec_kernel.Dba.Var.t ->
string option ->
addr:Binsec_kernel.Dba.Expr.t ->
Binsec_kernel.Machine.endianness ->
unitload p v m ~addr d assigns the variable v with the bytes read at the address addr from the memory array m.
When m is None, the load is performed from the main memory @.
The bit size of v should be a multiple of the size of a byte (8). The byte order is determined by the endianness d.
val store :
t ->
string option ->
addr:Binsec_kernel.Dba.Expr.t ->
Binsec_kernel.Dba.Expr.t ->
Binsec_kernel.Machine.endianness ->
unitstore p m ~addr e d writes the expression e at the address addr in the memory array m.
When m is None, the write is performed in the main memory @.
The bit size of e should be a multiple of the size of a byte (8). The byte order is determined by the endianness d.
val memcpy :
t ->
string option ->
addr:Binsec_kernel.Dba.Expr.t ->
int ->
Binsec_kernel.Loader_types.buffer ->
unitmemcpy p m ~addr len content initializes the memory array m at the address addr with len bytes from the zero extended buffer content.
When m is None, the write is performed in the main memory @.
Predicate query
val is_symbolic : t -> Binsec_kernel.Dba.Expr.t -> boolis_symbolic p e checks if the expression e may depend on symbolic values.
When it returns false, the path predicate of p implies that e has a single value. This value can be obtained via eval.
Otherwise, it means that e syntactically depends on a symbolic value. Use enumerate with n = 2 to prove or disprove that it can take several values.
val is_zero : t -> Binsec_kernel.Dba.Expr.t -> Binsec_symbolic.Path.trileanis_zero p e checks if the boolean expression e may depend on symbolic values.
It returns True when the path predicate implies e is false and False when the path predicate implies e is true.
Otherwise, it returns Unknown, that means that e syntactically depends on a symbolic value. Use enumerate with n = 2 to prove or disprove that it can take several values.
val assume : t -> Binsec_kernel.Dba.Expr.t -> model optionassume p e tests if the condition e can be true. If so, it returns a witness model (Some) and updates the symbolic predicate. Otherwise, nothing is updated and it returns None.
val check_sat_assuming :
t ->
?retain:bool ->
Binsec_kernel.Dba.Expr.t ->
model optioncheck_sat_assuming p ~retain e tests if the condition e can be true. If so, it returns a witness model (Some), otherwise, it returns None.
If retain is true (default), the model is saved into the path p.
val partition :
t ->
Binsec_kernel.Dba.Expr.t ->
(state, model) Binsec_symbolic.Path.partitionpartition p e tests if the condition e can be true and update its internal symbolic state accordingly.
It returns True when the path predicate implies e is true and False when the path predicate implies e is false.
It returns Trueish when the path predicate allows e to be true but may allow false too, and Falsish when the path predicate allows e to be false but may allow true too. The returned state can be used to check the other assumption.
It returns Split when the path predicate allows e to be both true and false. The current path keeps models for which e evaluates to true (same as assume) while the returned state comes with a list of models for which e evaluates to false.
val enumerate :
t ->
?retain:bool ->
?n:int ->
?accumulator:model Binsec_kernel.Bitvector.Map.t ->
?assuming:Binsec_kernel.Dba.Expr.t ->
Binsec_kernel.Dba.Expr.t ->
model Binsec_kernel.Bitvector.Map.tenumerate p ~retain ~n ~accumulator ~assuming e lists the possible values of the expression e.
It returns a map of up to n new possible values that are not already present in accumulator, together with their respective model witnesses. When n is omitted, the enumeration is unbounded.
The new models satisfy the predicate assuming when present.
If retain is true (default), new models are saved into the path p.
check_model p ~retain m returns true if the model m is a witness for the path predicate of p.
If retain is true (default), the model is saved into the path p when the function returns true.
Evaluation
val eval : t -> Binsec_kernel.Dba.Expr.t -> Binsec_kernel.Bitvector.teval p e evaluates the expression e in the last witness model.
The returned values are consistent with each other as long as the witness model is not updated via assume, check_sat_assuming, enumerate, check_model or partition.
val get_value : t -> Binsec_kernel.Dba.Expr.t -> valueget_value p e evaluates the expression e to its symbolic value.
val lookup : t -> Binsec_kernel.Dba.Var.t -> valuelookup p v evaluates the content of the variable v to its symbolic value.
val read :
t ->
string option ->
addr:Binsec_kernel.Dba.Expr.t ->
int ->
Binsec_kernel.Machine.endianness ->
valueread p m ~addr n d reads the content of the memory array m at the address addr.
When m is None, the load is performed from the main memory.
Returns a value of n bytes. The byte order is determined by the endianness d.
val symbols : t -> value list Binsec_kernel.Dba_types.Var.Map.tsymbols p returns the (reverse) history of symbols created by symbolize.
Custom storage
Second API (value)
module Value : Binsec_symbolic.State.VALUE with type t = valueval assign_v : t -> Binsec_kernel.Dba.Var.t -> value -> unitval load_v :
t ->
Binsec_kernel.Dba.Var.t ->
string option ->
addr:value ->
Binsec_kernel.Machine.endianness ->
unitval store_v :
t ->
string option ->
addr:value ->
value ->
Binsec_kernel.Machine.endianness ->
unitval memcpy_v :
t ->
string option ->
addr:value ->
int ->
Binsec_kernel.Loader_types.buffer ->
unitSame as is_symbolic but with value input.
val is_zero_v : t -> value -> Binsec_symbolic.Path.trileanSame as check_sat_assuming_v but with value input.
val partition_v : t -> value -> (state, model) Binsec_symbolic.Path.partitionval enumerate_v :
t ->
?retain:bool ->
?n:int ->
?accumulator:model Binsec_kernel.Bitvector.Map.t ->
?assuming:value ->
value ->
model Binsec_kernel.Bitvector.Map.tval eval_v : t -> value -> Binsec_kernel.Bitvector.tval read_v :
t ->
string option ->
addr:value ->
int ->
Binsec_kernel.Machine.endianness ->
valueDirect manipulation (unsafe)
val set_pc : t -> Binsec_kernel.Virtual_address.t -> unitset_pc p v replaces the current program counter of p by v.
set_models p l replaces the witness models of p by the ones in l.
Warning. It is the caller responsibility to ensure that l is non-empty and that each model in l is consistent with the current symbolic state state.
set_state p s replaces the symbolic state of p by s.
Warning. It is the caller responsibility to ensure that each model in models is consistent with the new symbolic state s.