mythril.laser.smt package
Subpackages
Submodules
mythril.laser.smt.array module
This module contains an SMT abstraction of arrays.
This includes an Array class to implement basic store and set operations, as well as as a K-array, which can be initialized with default values over a certain range.
- class mythril.laser.smt.array.Array(name: str, domain: int, value_range: int)[source]
Bases:
BaseArray
A basic symbolic array.
mythril.laser.smt.bitvec module
This module provides classes for an SMT abstraction of bit vectors.
- class mythril.laser.smt.bitvec.BitVec(raw: BitVecRef, annotations: Set[Any] | None = None)[source]
Bases:
Expression
[BitVecRef
]A bit vector symbol.
- property symbolic: bool
Returns whether this symbol doesn’t have a concrete value.
- Returns:
- property value: int | None
Returns the value of this symbol if concrete, otherwise None.
- Returns:
mythril.laser.smt.bitvec_helper module
- mythril.laser.smt.bitvec_helper.BVAddNoOverflow(a: BitVec | int, b: BitVec | int, signed: bool) Bool [source]
Creates predicate that verifies that the addition doesn’t overflow.
- Parameters:
a
b
signed
- Returns:
- mythril.laser.smt.bitvec_helper.BVMulNoOverflow(a: BitVec | int, b: BitVec | int, signed: bool) Bool [source]
Creates predicate that verifies that the multiplication doesn’t overflow.
- Parameters:
a
b
signed
- Returns:
- mythril.laser.smt.bitvec_helper.BVSubNoUnderflow(a: BitVec | int, b: BitVec | int, signed: bool) Bool [source]
Creates predicate that verifies that the subtraction doesn’t overflow.
- Parameters:
a
b
signed
- Returns:
- mythril.laser.smt.bitvec_helper.Concat(*args: List[BitVec]) BitVec [source]
- mythril.laser.smt.bitvec_helper.Concat(*args: BitVec) BitVec
Create a concatenation expression.
- Parameters:
args
- Returns:
- mythril.laser.smt.bitvec_helper.Extract(high: int, low: int, bv: BitVec) BitVec [source]
Create an extract expression.
- Parameters:
high
low
bv
- Returns:
- mythril.laser.smt.bitvec_helper.If(a: Bool | bool, b: BitVec | int, c: BitVec | int) BitVec [source]
- mythril.laser.smt.bitvec_helper.If(a: Bool | bool, b: BaseArray, c: BaseArray) BaseArray
Create an if-then-else expression.
- Parameters:
a
b
c
- Returns:
- mythril.laser.smt.bitvec_helper.SRem(a: BitVec, b: BitVec) BitVec [source]
Create a signed remainder expression.
- Parameters:
a
b
- Returns:
- mythril.laser.smt.bitvec_helper.UDiv(a: BitVec, b: BitVec) BitVec [source]
Create an unsigned division expression.
- Parameters:
a
b
- Returns:
- mythril.laser.smt.bitvec_helper.UGE(a: BitVec, b: BitVec) Bool [source]
Create an unsigned greater than or equal to expression.
- Parameters:
a
b
- Returns:
- mythril.laser.smt.bitvec_helper.UGT(a: BitVec, b: BitVec) Bool [source]
Create an unsigned greater than expression.
- Parameters:
a
b
- Returns:
- mythril.laser.smt.bitvec_helper.ULE(a: BitVec, b: BitVec) Bool [source]
Create an unsigned less than or equal to expression.
- Parameters:
a
b
- Returns:
mythril.laser.smt.bool module
This module provides classes for an SMT abstraction of boolean expressions.
- class mythril.laser.smt.bool.Bool(raw: T, annotations: Set[Any] | None = None)[source]
Bases:
Expression
[BoolRef
]This is a Bool expression.
- property is_false: bool
Specifies whether this variable can be simplified to false.
- Returns:
- property is_true: bool
Specifies whether this variable can be simplified to true.
- Returns:
- substitute(original_expression, new_expression)[source]
- Parameters:
original_expression
new_expression
- property value: bool | None
Returns the concrete value of this bool if concrete, otherwise None.
- Returns:
Concrete value or None
- mythril.laser.smt.bool.Or(*args: Bool | bool) Bool [source]
Create an or expression.
- Parameters:
a
b
- Returns:
mythril.laser.smt.expression module
This module contains the SMT abstraction for a basic symbol expression.
- class mythril.laser.smt.expression.Expression(raw: T, annotations: Set[Any] | None = None)[source]
Bases:
Generic
[T
]This is the base symbol class and maintains functionality for simplification and annotations.
- annotate(annotation: Any) None [source]
Annotates this expression with the given annotation.
- Parameters:
annotation
- property annotations: Set[Any]
Gets the annotations for this expression.
- Returns:
mythril.laser.smt.function module
mythril.laser.smt.model module
- class mythril.laser.smt.model.Model(models: List[ModelRef] | None = None)[source]
Bases:
object
The model class wraps a z3 model
This implementation allows for multiple internal models, this is required for the use of an independence solver which has models for multiple queries which need an uniform output.
- eval(expression: ExprRef, model_completion: bool = False) None | ExprRef [source]
Evaluate the expression using this model
- Parameters:
expression – The expression to evaluate
model_completion – Use the default value if the model has no interpretation of the given expression
- Returns:
The evaluated expression
Module contents
- class mythril.laser.smt.SymbolFactory[source]
Bases:
Generic
[T
,U
]A symbol factory provides a default interface for all the components of mythril to create symbols
- static BitVecSym(name: str, size: int, annotations: Set[Any] | None = None) U [source]
Creates a new bit vector with a symbolic value.
- Parameters:
name – The name of the symbolic bit vector
size – The size of the bit vector
annotations – The annotations to initialize the bit vector with
- Returns:
The freshly created bit vector
- static BitVecVal(value: int, size: int, annotations: Set[Any] | None = None) U [source]
Creates a new bit vector with a concrete value.
- Parameters:
value – The concrete value to set the bit vector to
size – The size of the bit vector
annotations – The annotations to initialize the bit vector with
- Returns:
The freshly created bit vector