maat.VarContext class

This class holds a mapping between abstract variables and concrete values. It is used to perform concolic execution, so that abstract symbolic variables can be concretized.

❱   Methods

int get(str name)

Get an abstract variable concrete value

Parameters
name Name of the abstract variable

bytes get_as_buffer(str base_name, Optional[int elem_size=1])

Return a buffer built from the name base_name. This method iterates on all variables that are named "base_name_0", "base_name_1", etc, until there are no matching variables and returns the buffer built by concatenating their individual values reduced or extended to elem_size bytes

Parameters
base_name Name of the abstract variable
elem_size Size in bytes of each buffer element

str get_as_str(str base_name)

Similar to VarContext.get_as_buffer(). Return a string built from the name base_name. This method iterates on all variables that are named "base_name_0", "base_name_1", etc, until there are no matching variables or one variable has a null value, and returns the string built by concatenating their individual values interpreted as chars

set(str name, int val)

Set concrete value for abstract variable

Parameters
name Name of the abstract variable
val Concrete value for the variable

remove(str name)

Unbind a variabe from its concrete value. The variable becomes purely symbolic in this context

Parameters
name Name of the variable

bool contains(str name)

Return True if the variable name is bound to a concrete value in this context

update_from( VarContext other)

Update the context contents from another context. All variables and associated concrete values are copied from other. If a variable exists both in this context and in other, it takes the value it has in other

list[ Value ] new_symbolic_buffer(str name, int nb_elems, int elem_size=1, Optional[int] trailing_value=None)

Return a new buffer of symbolic variables

Parameters
name Base name for the abstract variables
nb_elems Number of variables to create
elem_size Size of each variable in bytes
trailing_value If specified, append a concrete value to the returned buffer. The trailing value is not included in the nb_elems count

list[ Value ] new_concolic_buffer(str name, Union[list[int],bytes] concrete_buffer, int nb_elems, int elem_size=1, Optional[int] trailing_value=None)

Return a new buffer of concolic variables

Parameters
name Base name for the abstract variables
concrete_buffer Concrete values to assign to bind to the created abstract variables. If a list of integer is used,each variable gets its value from the corresponding int in the list. If a bytes object is used, each variable gets its value from the concrete bytes according to elem_size and nb_elems so that writing the resulting concolic buffer to memory matches concrete_buffer
nb_elems Number of variables to create
elem_size Size of each variable in bytes
trailing_value If specified, append a concrete value to the returned buffer. The trailing value is not included in the nb_elems count