INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Reloads the solver. Useful when changing solver options. | def reload_solver(self, constraints=None):
"""
Reloads the solver. Useful when changing solver options.
:param list constraints: A new list of constraints to use in the reloaded solver instead of the current one
"""
if constraints is None:
constraints = self._sol... |
Iterate over all variables for which their tracking key is a prefix of the values provided. | def get_variables(self, *keys):
"""
Iterate over all variables for which their tracking key is a prefix of the values provided.
Elements are a tuple, the first element is the full tracking key, the second is the symbol.
>>> list(s.solver.get_variables('mem'))
[(('mem', 0x1000),... |
Register a value with the variable tracking system | def register_variable(self, v, key, eternal=True):
"""
Register a value with the variable tracking system
:param v: The BVS to register
:param key: A tuple to register the variable under
:parma eternal: Whether this is an eternal variable, default True. If False, an in... |
Given an AST iterate over all the keys of all the BVS leaves in the tree which are registered. | def describe_variables(self, v):
"""
Given an AST, iterate over all the keys of all the BVS leaves in the tree which are registered.
"""
reverse_mapping = {next(iter(var.variables)): k for k, var in self.eternal_tracked_variables.items()}
reverse_mapping.update({next(iter(var.var... |
Creates or gets a Claripy solver based on the state options. | def _solver(self):
"""
Creates or gets a Claripy solver, based on the state options.
"""
if self._stored_solver is not None:
return self._stored_solver
track = o.CONSTRAINT_TRACKING_IN_SOLVER in self.state.options
approximate_first = o.APPROXIMATE_FIRST in se... |
Creates an unconstrained symbol or a default concrete value ( 0 ) based on the state options. | def Unconstrained(self, name, bits, uninitialized=True, inspect=True, events=True, key=None, eternal=False, **kwargs):
"""
Creates an unconstrained symbol or a default concrete value (0), based on the state options.
:param name: The name of the symbol.
:param bits: ... |
Creates a bit - vector symbol ( i. e. a variable ). Other keyword parameters are passed directly on to the constructor of claripy. ast. BV. | def BVS(self, name, size,
min=None, max=None, stride=None,
uninitialized=False,
explicit_name=None, key=None, eternal=False,
inspect=True, events=True,
**kwargs): #pylint:disable=redefined-builtin
"""
Creates a bit-vector symbol (i.e., a variab... |
Evaluate an expression using the solver if necessary. Returns AST objects. | def eval_to_ast(self, e, n, extra_constraints=(), exact=None):
"""
Evaluate an expression, using the solver if necessary. Returns AST objects.
:param e: the expression
:param n: the number of desired solutions
:param extra_constraints: extra constraints to apply to the solver
... |
Evaluate an expression using the solver if necessary. Returns primitives. | def _eval(self, e, n, extra_constraints=(), exact=None):
"""
Evaluate an expression, using the solver if necessary. Returns primitives.
:param e: the expression
:param n: the number of desired solutions
:param extra_constraints: extra constraints to apply to the solver
:... |
Return the maximum value of expression e. | def max(self, e, extra_constraints=(), exact=None):
"""
Return the maximum value of expression `e`.
:param e : expression (an AST) to evaluate
:param extra_constraints: extra constraints (as ASTs) to add to the solver for this solve
:param exact : if Fa... |
Return True if v is a solution of expr with the extra constraints False otherwise. | def solution(self, e, v, extra_constraints=(), exact=None):
"""
Return True if `v` is a solution of `expr` with the extra constraints, False otherwise.
:param e: An expression (an AST) to evaluate
:param v: The proposed solution (an AST)
:para... |
This function returns the unsat core from the backend solver. | def unsat_core(self, extra_constraints=()):
"""
This function returns the unsat core from the backend solver.
:param extra_constraints: Extra constraints (as ASTs) to add to the solver for this solve.
:return: The unsat core.
"""
if o.CONSTRAINT_TRACKING_IN_SOLVER not ... |
This function does a constraint check and checks if the solver is in a sat state. | def satisfiable(self, extra_constraints=(), exact=None):
"""
This function does a constraint check and checks if the solver is in a sat state.
:param extra_constraints: Extra constraints (as ASTs) to add to s for this solve
:param exact: If False, return approximate solu... |
Add some constraints to the solver. | def add(self, *constraints):
"""
Add some constraints to the solver.
:param constraints: Pass any constraints that you want to add (ASTs) as varargs.
"""
cc = self._adjust_constraint_list(constraints)
return self._solver.add(cc) |
Casts a solution for the given expression to type cast_to. | def _cast_to(e, solution, cast_to):
"""
Casts a solution for the given expression to type `cast_to`.
:param e: The expression `value` is a solution for
:param value: The solution to be cast
:param cast_to: The type `value` should be cast to. Must be one of the currently supporte... |
Evaluate an expression using the solver if necessary. Returns primitives as specified by the cast_to parameter. Only certain primitives are supported check the implementation of _cast_to to see which ones. | def eval_upto(self, e, n, cast_to=None, **kwargs):
"""
Evaluate an expression, using the solver if necessary. Returns primitives as specified by the `cast_to`
parameter. Only certain primitives are supported, check the implementation of `_cast_to` to see which ones.
:param e: the expres... |
Evaluate an expression to get the only possible solution. Errors if either no or more than one solution is returned. A kwarg parameter default can be specified to be returned instead of failure! | def eval_one(self, e, **kwargs):
"""
Evaluate an expression to get the only possible solution. Errors if either no or more than one solution is
returned. A kwarg parameter `default` can be specified to be returned instead of failure!
:param e: the expression to get a solution for
... |
Evaluate an expression to get at most n possible solutions. Errors if either none or more than n solutions are returned. | def eval_atmost(self, e, n, **kwargs):
"""
Evaluate an expression to get at most `n` possible solutions. Errors if either none or more than `n` solutions
are returned.
:param e: the expression to get a solution for
:param n: the inclusive upper limit on the number of solutions
... |
Returns True if the expression e has only one solution by querying the constraint solver. It does also add that unique solution to the solver s constraints. | def unique(self, e, **kwargs):
"""
Returns True if the expression `e` has only one solution by querying
the constraint solver. It does also add that unique solution to the
solver's constraints.
"""
if not isinstance(e, claripy.ast.Base):
return True
#... |
Returns True if the expression e is symbolic. | def symbolic(self, e): # pylint:disable=R0201
"""
Returns True if the expression `e` is symbolic.
"""
if type(e) in (int, bytes, float, bool):
return False
return e.symbolic |
Returns True whether e is a concrete value or is a value set with only 1 possible value. This differs from unique in that this * does * not query the constraint solver. | def single_valued(self, e):
"""
Returns True whether `e` is a concrete value or is a value set with
only 1 possible value. This differs from `unique` in that this *does*
not query the constraint solver.
"""
if self.state.mode == 'static':
if type(e) in (int, b... |
Simplifies e. If e is None simplifies the constraints of this state. | def simplify(self, e=None):
"""
Simplifies `e`. If `e` is None, simplifies the constraints of this
state.
"""
if e is None:
return self._solver.simplify()
elif isinstance(e, (int, float, bool)):
return e
elif isinstance(e, claripy.ast.Base)... |
Add a preconstraint that variable == value to the state. | def preconstrain(self, value, variable):
"""
Add a preconstraint that ``variable == value`` to the state.
:param value: The concrete value. Can be a bitvector or a bytestring or an integer.
:param variable: The BVS to preconstrain.
"""
if not isinstance(value, c... |
Preconstrain the contents of a file. | def preconstrain_file(self, content, simfile, set_length=False):
"""
Preconstrain the contents of a file.
:param content: The content to preconstrain the file to. Can be a bytestring or a list thereof.
:param simfile: The actual simfile to preconstrain
"""
repair... |
Preconstrain the data in the flag page. | def preconstrain_flag_page(self, magic_content):
"""
Preconstrain the data in the flag page.
:param magic_content: The content of the magic page as a bytestring.
"""
for m, v in zip(magic_content, self.state.cgc.flag_bytes):
self.preconstrain(m, v) |
Remove the preconstraints from the state. | def remove_preconstraints(self, to_composite_solver=True, simplify=True):
"""
Remove the preconstraints from the state.
If you are using the zen plugin, this will also use that to filter the constraints.
:param to_composite_solver: Whether to convert the replacement solver to a com... |
Split the solver. If any of the subsolvers time out after a short timeout ( 10 seconds ) re - add the preconstraints associated with each of its variables. Hopefully these constraints still allow us to do meaningful things to the state. | def reconstrain(self):
"""
Split the solver. If any of the subsolvers time out after a short timeout (10 seconds), re-add the
preconstraints associated with each of its variables. Hopefully these constraints still allow us to do
meaningful things to the state.
"""
# test... |
Add a reference to a memory data object. | def add_ref(self, ref):
"""
Add a reference to a memory data object.
:param CodeReference ref: The reference.
:return: None
"""
self.refs[ref.insn_addr].append(ref)
self.data_addr_to_ref[ref.memory_data.addr].append(ref) |
Get an arbitrary CFGNode ( without considering their contexts ) from our graph. | def get_any_node(self, addr, is_syscall=None, anyaddr=False, force_fastpath=False):
"""
Get an arbitrary CFGNode (without considering their contexts) from our graph.
:param int addr: Address of the beginning of the basic block. Set anyaddr to True to support arbitrary
... |
Get all CFGNodes whose address is the specified one. | def get_all_nodes(self, addr, is_syscall=None, anyaddr=False):
"""
Get all CFGNodes whose address is the specified one.
:param addr: Address of the node
:param is_syscall: True returns the syscall node, False returns the normal CFGNode, None returns both
:return: ... |
Get predecessors of a node in the control flow graph. | def get_predecessors(self, cfgnode, excluding_fakeret=True, jumpkind=None):
"""
Get predecessors of a node in the control flow graph.
:param CFGNode cfgnode: The node.
:param bool excluding_fakeret: True if you want to exclude all predecessors that is connected to the n... |
Get successors of a node in the control flow graph. | def get_successors(self, node, excluding_fakeret=True, jumpkind=None):
"""
Get successors of a node in the control flow graph.
:param CFGNode node: The node.
:param bool excluding_fakeret: True if you want to exclude all successors that is connected to the node
... |
Get a list of tuples where the first element is the successor of the CFG node and the second element is the jumpkind of the successor. | def get_successors_and_jumpkind(self, node, excluding_fakeret=True):
"""
Get a list of tuples where the first element is the successor of the CFG node and the second element is the
jumpkind of the successor.
:param CFGNode node: The node.
:param bool excluding_fakeret... |
Get all predecessors of a specific node on the control flow graph. | def get_all_predecessors(self, cfgnode):
"""
Get all predecessors of a specific node on the control flow graph.
:param CFGNode cfgnode: The CFGNode object
:return: A list of predecessors in the CFG
:rtype: list
"""
s = set()
for child, parent in networkx.... |
Returns all nodes that has an out degree > = 2 | def get_branching_nodes(self):
"""
Returns all nodes that has an out degree >= 2
"""
nodes = set()
for n in self.graph.nodes():
if self.graph.out_degree(n) >= 2:
nodes.add(n)
return nodes |
Get the corresponding exit statement ID for control flow to reach destination block from source block. The exit statement ID was put on the edge when creating the CFG. Note that there must be a direct edge between the two blocks otherwise an exception will be raised. | def get_exit_stmt_idx(self, src_block, dst_block):
"""
Get the corresponding exit statement ID for control flow to reach destination block from source block. The exit
statement ID was put on the edge when creating the CFG.
Note that there must be a direct edge between the two blocks, oth... |
Hook target for native function call returns. | def prepare_native_return_state(native_state):
"""
Hook target for native function call returns.
Recovers and stores the return value from native memory and toggles the
state, s.t. execution continues in the Soot engine.
"""
javavm_simos = native_state.project.simos
... |
Return a concretization of the contents of the file as a flat bytestring. | def concretize(self, **kwargs):
"""
Return a concretization of the contents of the file, as a flat bytestring.
"""
size = self.state.solver.min(self._size, **kwargs)
data = self.load(0, size)
kwargs['cast_to'] = kwargs.get('cast_to', bytes)
kwargs['extra_constrai... |
Returns a list of the packets read or written as bytestrings. | def concretize(self, **kwargs):
"""
Returns a list of the packets read or written as bytestrings.
"""
lengths = [self.state.solver.eval(x[1], **kwargs) for x in self.content]
kwargs['cast_to'] = bytes
return [b'' if i == 0 else self.state.solver.eval(x[0][i*self.state.arc... |
Read a packet from the stream. | def read(self, pos, size, **kwargs):
"""
Read a packet from the stream.
:param int pos: The packet number to read from the sequence of the stream. May be None to append to the stream.
:param size: The size to read. May be symbolic.
:param short_reads: Whether to repla... |
Write a packet to the stream. | def write(self, pos, data, size=None, events=True, **kwargs):
"""
Write a packet to the stream.
:param int pos: The packet number to write in the sequence of the stream. May be None to append to the stream.
:param data: The data to write, as a string or bitvector.
:pa... |
Reads some data from the file storing it into memory. | def read(self, pos, size, **kwargs):
"""
Reads some data from the file, storing it into memory.
:param pos: The address to write the read data into memory
:param size: The requested length of the read
:return: The real length of the read
"""
data, r... |
Writes some data loaded from the state into the file. | def write(self, pos, size, **kwargs):
"""
Writes some data, loaded from the state, into the file.
:param pos: The address to read the data to write from in memory
:param size: The requested size of the write
:return: The real length of the write
"""
... |
Return a concretization of the underlying files as a tuple of ( read file write file ). | def concretize(self, **kwargs):
"""
Return a concretization of the underlying files, as a tuple of (read file, write file).
"""
return (self._read_file.concretize(**kwargs), self._write_file.concretize(**kwargs)) |
Find a sinkhole which is large enough to support length bytes. | def get_max_sinkhole(self, length):
"""
Find a sinkhole which is large enough to support `length` bytes.
This uses first-fit. The first sinkhole (ordered in descending order by their address)
which can hold `length` bytes is chosen. If there are more than `length` bytes in the
s... |
A decorator function you should apply to copy | def memo(f):
"""
A decorator function you should apply to ``copy``
"""
def inner(self, memo=None, **kwargs):
if memo is None:
memo = {}
if id(self) in memo:
return memo[id(self)]
else:
c = f(self, memo, *... |
Appended a new state to this VFGNode.: param s: The new state to append: param is_widened_state: Whether it is a widened state or not. | def append_state(self, s, is_widened_state=False):
"""
Appended a new state to this VFGNode.
:param s: The new state to append
:param is_widened_state: Whether it is a widened state or not.
"""
if not is_widened_state:
self.all_states.append(s)
se... |
Get the first FunctionAnalysis task in the stack. | def _top_function_analysis_task(self):
"""
Get the first FunctionAnalysis task in the stack.
:return: The top function analysis task in the stack, or None if there isn't any.
:rtype: FunctionAnalysis
"""
for r in reversed(self._task_stack):
if isinstance(r, ... |
Get any VFG node corresponding to the basic block at | def get_any_node(self, addr):
"""
Get any VFG node corresponding to the basic block at @addr.
Note that depending on the context sensitivity level, there might be
multiple nodes corresponding to different contexts. This function will
return the first one it encounters, which migh... |
Executed before analysis starts. Necessary initializations are performed here. | def _pre_analysis(self):
"""
Executed before analysis starts. Necessary initializations are performed here.
:return: None
"""
l.debug("Starting from %#x", self._start)
# initialize the task stack
self._task_stack = [ ]
# initialize the execution counte... |
Get the sorting key of a VFGJob instance. | def _job_sorting_key(self, job):
"""
Get the sorting key of a VFGJob instance.
:param VFGJob job: the VFGJob object.
:return: An integer that determines the order of this job in the queue.
:rtype: int
"""
MAX_BLOCKS_PER_FUNCTION = 1000000
task_functions... |
Some code executed before actually processing the job. | def _pre_job_handling(self, job):
"""
Some code executed before actually processing the job.
:param VFGJob job: the VFGJob object.
:return: None
"""
# did we reach the final address?
if self._final_address is not None and job.addr == self._final_address:
... |
Process each successor generated by the job and return a new list of succeeding jobs. | def _handle_successor(self, job, successor, all_successors):
"""
Process each successor generated by the job, and return a new list of succeeding jobs.
:param VFGJob job: The VFGJob instance.
:param SimState successor: The succeeding state.
:param list all_successors: A list of... |
Generate new jobs for all possible successor targets when there are more than one possible concrete value for successor. ip | def _handle_successor_multitargets(self, job, successor, all_successors):
"""
Generate new jobs for all possible successor targets when there are more than one possible concrete value for
successor.ip
:param VFGJob job: The VFGJob instance.
:param SimState successor: The succeed... |
Merge two given states and return a new one. | def _merge_states(self, old_state, new_state):
"""
Merge two given states, and return a new one.
:param old_state:
:param new_state:
:returns: The merged state, and whether a merging has occurred
"""
# print old_state.dbg_print_stack()
# print new_state.... |
Perform widen operation on the given states and return a new one. | def _widen_states(old_state, new_state):
"""
Perform widen operation on the given states, and return a new one.
:param old_state:
:param new_state:
:returns: The widened state, and whether widening has occurred
"""
# print old_state.dbg_print_stack()
# p... |
Try to narrow the state! | def _narrow_states(node, old_state, new_state, previously_widened_state): # pylint:disable=unused-argument,no-self-use
"""
Try to narrow the state!
:param old_state:
:param new_state:
:param previously_widened_state:
:returns: The narrowed state, and whether a narrowing... |
Get the state to start the analysis for function. | def _prepare_initial_state(self, function_start, state):
"""
Get the state to start the analysis for function.
:param int function_start: Address of the function
:param SimState state: The program state to base on.
"""
if state is None:
state = self.project.... |
Set the return address of the current state to a specific address. We assume we are at the beginning of a function or in other words we are about to execute the very first instruction of the function. | def _set_return_address(self, state, ret_addr):
"""
Set the return address of the current state to a specific address. We assume we are at the beginning of a
function, or in other words, we are about to execute the very first instruction of the function.
:param SimState state: The progr... |
Create a DiGraph out of the existing edge map.: param return_target_sources: Used for making up those missing returns: returns: A networkx. DiGraph () object | def _create_graph(self, return_target_sources=None):
"""
Create a DiGraph out of the existing edge map.
:param return_target_sources: Used for making up those missing returns
:returns: A networkx.DiGraph() object
"""
if return_target_sources is None:
# We set ... |
Get an existing VFGNode instance from the graph. | def _graph_get_node(self, block_id, terminator_for_nonexistent_node=False):
"""
Get an existing VFGNode instance from the graph.
:param BlockID block_id: The block ID for the node to get.
:param bool terminator_for_nonexistent_node: True if a Terminator (which is a S... |
Add an edge onto the graph. | def _graph_add_edge(self, src_block_id, dst_block_id, **kwargs):
"""
Add an edge onto the graph.
:param BlockID src_block_id: The block ID for source node.
:param BlockID dst_block_id: The block Id for destination node.
:param str jumpkind: The jumpkind of the edge.
... |
Create a list of new VFG jobs for the successor state. | def _create_new_jobs(self, job, successor, new_block_id, new_call_stack):
"""
Create a list of new VFG jobs for the successor state.
:param VFGJob job: The VFGJob instance.
:param SimState successor: The succeeding state.
:param BlockID new_block_id: Block ... |
Remove all pending returns that are related to the current job. | def _remove_pending_return(self, job, pending_returns):
"""
Remove all pending returns that are related to the current job.
"""
# Build the tuples that we want to remove from the dict fake_func_retn_exits
tpls_to_remove = [ ]
call_stack_copy = job.call_stack_copy()
... |
Print out debugging information after handling a VFGJob and generating the succeeding jobs. | def _post_job_handling_debug(self, job, successors):
"""
Print out debugging information after handling a VFGJob and generating the succeeding jobs.
:param VFGJob job: The VFGJob instance.
:param list successors: A list of succeeding states.
:return: None
"""
fu... |
Save the initial state of a function and merge it with existing ones if there are any. | def _save_function_initial_state(self, function_key, function_address, state):
"""
Save the initial state of a function, and merge it with existing ones if there are any.
:param FunctionKey function_key: The key to this function.
:param int function_address: Address of the function.
... |
Save the final state of a function and merge it with existing ones if there are any. | def _save_function_final_state(self, function_key, function_address, state):
"""
Save the final state of a function, and merge it with existing ones if there are any.
:param FunctionKey function_key: The key to this function.
:param int function_address: Address of the function.
... |
Get the possible ( networkx ) simple paths between two nodes or addresses corresponding to nodes. Input: addresses or node instances Return: a list of lists of nodes representing paths. | def _get_nx_paths(self, begin, end):
"""
Get the possible (networkx) simple paths between two nodes or addresses
corresponding to nodes.
Input: addresses or node instances
Return: a list of lists of nodes representing paths.
"""
if type(begin) is int and type(end)... |
Return the ordered merge points for a specific function. | def _merge_points(self, function_address):
"""
Return the ordered merge points for a specific function.
:param int function_address: Address of the querying function.
:return: A list of sorted merge points (addresses).
:rtype: list
"""
# we are entering a new fu... |
Return the ordered widening points for a specific function. | def _widening_points(self, function_address):
"""
Return the ordered widening points for a specific function.
:param int function_address: Address of the querying function.
:return: A list of sorted merge points (addresses).
:rtype: list
"""
# we are entering a ... |
For a given function return all nodes in an optimal traversal order. If the function does not exist return an empty list. | def _ordered_node_addrs(self, function_address):
"""
For a given function, return all nodes in an optimal traversal order. If the function does not exist, return an
empty list.
:param int function_address: Address of the function.
:return: A ordered list of the nodes.
:r... |
Assign a new region for under - constrained symbolic execution. | def assign(self, dst_addr_ast):
"""
Assign a new region for under-constrained symbolic execution.
:param dst_addr_ast: the symbolic AST which address of the new allocated region will be assigned to.
:return: as ast of memory address that points to a new region
"""
if ds... |
Test whether an AST is bounded by any existing constraint in the related solver. | def is_bounded(self, ast):
"""
Test whether an AST is bounded by any existing constraint in the related solver.
:param ast: an claripy.AST object
:return: True if there is at least one related constraint, False otherwise
"""
return len(ast.variables.intersection(self.st... |
Resolves the indirect jump in MIPS ELF binaries where all external function calls are indexed using gp. | def resolve(self, cfg, addr, func_addr, block, jumpkind):
"""
Resolves the indirect jump in MIPS ELF binaries where all external function calls are indexed using gp.
:param cfg: A CFG instance.
:param int addr: IRSB address.
:param int func_addr: The function address.
:p... |
Perform execution with a state. | def process(self, state, procedure=None, force_addr=None, **kwargs):
"""
Perform execution with a state.
:param state: The state with which to execute
:param procedure: An instance of a SimProcedure to run, optional
:param ret_to: The address to return to when this ... |
[ COMPATIBILITY ] Make a copy of the current instance and then discard all options that are in boolean_switches. | def difference(self, boolean_switches):
"""
[COMPATIBILITY]
Make a copy of the current instance, and then discard all options that are in boolean_switches.
:param set boolean_switches: A collection of Boolean switches to disable.
:return: A new SimState... |
Return a string representation of all state options. | def tally(self, exclude_false=True, description=False):
"""
Return a string representation of all state options.
:param bool exclude_false: Whether to exclude Boolean switches that are disabled.
:param bool description: Whether to display the description of each option.
:ret... |
Register a state option. | def register_option(cls, name, types, default=None, description=None):
"""
Register a state option.
:param str name: Name of the state option.
:param types: A collection of allowed types of this state option.
:param default: The default value of this sta... |
Register a Boolean switch as state option. This is equivalent to cls. register_option ( name set ( [ bool ] ) description = description ) | def register_bool_option(cls, name, description=None):
"""
Register a Boolean switch as state option.
This is equivalent to cls.register_option(name, set([bool]), description=description)
:param str name: Name of the state option.
:param str description: The description o... |
For now a lot of naive concretization is done when handling heap metadata to keep things manageable. This idiom showed up a lot as a result so to reduce code repetition this function uses a callback to handle the one or two operations that varied across invocations. | def concretize(x, solver, sym_handler):
"""
For now a lot of naive concretization is done when handling heap metadata to keep things manageable. This idiom
showed up a lot as a result, so to reduce code repetition this function uses a callback to handle the one or two
operations that varied across invoc... |
return a 5 - tuple of strings sufficient for formatting with %s%s%s%s%s to verbosely describe the procedure | def _describe_me(self):
"""
return a 5-tuple of strings sufficient for formatting with ``%s%s%s%s%s`` to verbosely describe the procedure
"""
return (
self.display_name,
' (cont: %s)' % self.run_func if self.is_continuation else '',
' (syscall)' if sel... |
Call this method with a SimState and a SimSuccessors to execute the procedure. | def execute(self, state, successors=None, arguments=None, ret_to=None):
"""
Call this method with a SimState and a SimSuccessors to execute the procedure.
Alternately, successors may be none if this is an inline call. In that case, you should
provide arguments to the function.
"... |
Returns the ith argument. Raise a SimProcedureArgumentError if we don t have such an argument available. | def arg(self, i):
"""
Returns the ith argument. Raise a SimProcedureArgumentError if we don't have such an argument available.
:param int i: The index of the argument to get
:return: The argument
:rtype: object
"""
if self.use_state_arguments:
r = sel... |
Call another SimProcedure in - line to retrieve its return value. Returns an instance of the procedure with the ret_expr property set. | def inline_call(self, procedure, *arguments, **kwargs):
"""
Call another SimProcedure in-line to retrieve its return value.
Returns an instance of the procedure with the ret_expr property set.
:param procedure: The class of the procedure to execute
:param arguments: ... |
Add an exit representing a return from this function. If this is not an inline call grab a return address from the state and jump to it. If this is not an inline call set a return expression with the calling convention. | def ret(self, expr=None):
"""
Add an exit representing a return from this function.
If this is not an inline call, grab a return address from the state and jump to it.
If this is not an inline call, set a return expression with the calling convention.
"""
self.inhibit_aut... |
Add an exit representing calling another function via pointer. | def call(self, addr, args, continue_at, cc=None):
"""
Add an exit representing calling another function via pointer.
:param addr: The address of the function to call
:param args: The list of arguments to call the function with
:param continue_at: Later, when the ca... |
Add an exit representing jumping to an address. | def jump(self, addr):
"""
Add an exit representing jumping to an address.
"""
self.inhibit_autoret = True
self._exit_action(self.state, addr)
self.successors.add_successor(self.state, addr, self.state.solver.true, 'Ijk_Boring') |
Add an exit representing terminating the program. | def exit(self, exit_code):
"""
Add an exit representing terminating the program.
"""
self.inhibit_autoret = True
self.state.options.discard(o.AST_DEPS)
self.state.options.discard(o.AUTO_REFS)
if isinstance(exit_code, int):
exit_code = self.state.solve... |
Starting from the start_node explore the entire VFG and perform the following: - Generate def - use chains for all registers and memory addresses using a worklist | def _explore(self):
"""
Starting from the start_node, explore the entire VFG, and perform the following:
- Generate def-use chains for all registers and memory addresses using a worklist
"""
# TODO: The worklist algorithm can definitely use some optimizations. It is a future wor... |
Given all live definitions prior to this program point track the changes and return a new list of live definitions. We scan through the action list of the new state to track the changes. | def _track(self, state, live_defs):
"""
Given all live definitions prior to this program point, track the changes, and return a new list of live
definitions. We scan through the action list of the new state to track the changes.
:param state: The input state at that program point.... |
This is a backward lookup in the previous defs. | def _def_lookup(self, live_defs, variable):
"""
This is a backward lookup in the previous defs.
:param addr_list: a list of normalized addresses.
Note that, as we are using VSA, it is possible that @a is affected by several definitions.
:returns: a dict {s... |
Kill previous defs. addr_list is a list of normalized addresses. | def _kill(self, live_defs, variable, code_loc):
"""
Kill previous defs. `addr_list` is a list of normalized addresses.
"""
# Case 1: address perfectly match, we kill
# Case 2: a is a subset of the original address
# Case 3: a is a superset of the original address
... |
Add an edge in the graph from s_a to statement s_b where s_a and s_b are tuples of statements of the form ( irsb_addr stmt_idx ). | def _add_edge(self, s_a, s_b, **edge_labels):
"""
Add an edge in the graph from `s_a` to statement `s_b`, where `s_a` and `s_b` are tuples of statements of the
form (irsb_addr, stmt_idx).
"""
# Is that edge already in the graph ?
# If at least one is new, then we are not ... |
Get all DDG nodes matching the given basic block address and statement index. | def get_all_nodes(self, simrun_addr, stmt_idx):
"""
Get all DDG nodes matching the given basic block address and statement index.
"""
nodes=[]
for n in self.graph.nodes():
if n.simrun_addr == simrun_addr and n.stmt_idx == stmt_idx:
nodes.add(n)
... |
Yields each of the individual lane pairs from the arguments in order from most significan to least significant | def vector_args(self, args):
"""
Yields each of the individual lane pairs from the arguments, in
order from most significan to least significant
"""
for i in reversed(range(self._vector_count)):
pieces = []
for vec in args:
pieces.append(... |
Count the leading zeroes | def _op_generic_Clz(self, args):
"""Count the leading zeroes"""
wtf_expr = claripy.BVV(self._from_size, self._from_size)
for a in range(self._from_size):
bit = claripy.Extract(a, a, args[0])
wtf_expr = claripy.If(bit==1, claripy.BVV(self._from_size-a-1, self._from_size), ... |
Count the trailing zeroes | def _op_generic_Ctz(self, args):
"""Count the trailing zeroes"""
wtf_expr = claripy.BVV(self._from_size, self._from_size)
for a in reversed(range(self._from_size)):
bit = claripy.Extract(a, a, args[0])
wtf_expr = claripy.If(bit == 1, claripy.BVV(a, self._from_size), wtf_e... |
Halving add for some ARM NEON instructions. | def _op_generic_HAdd(self, args):
"""
Halving add, for some ARM NEON instructions.
"""
components = []
for a, b in self.vector_args(args):
if self.is_signed:
a = a.sign_extend(self._vector_size)
b = b.sign_extend(self._vector_size)
... |
Saturating add. | def _op_generic_QAdd(self, args):
"""
Saturating add.
"""
components = []
for a, b in self.vector_args(args):
top_a = a[self._vector_size-1]
top_b = b[self._vector_size-1]
res = a + b
top_r = res[self._vector_size-1]
if ... |
Generic pack with unsigned saturation. Split args in chunks of src_size signed bits and in pack them into unsigned saturated chunks of dst_size bits. Then chunks are concatenated resulting in a BV of len ( args ) * dst_size// src_size * len ( args [ 0 ] ) bits. | def _op_generic_pack_StoU_saturation(self, args, src_size, dst_size):
"""
Generic pack with unsigned saturation.
Split args in chunks of src_size signed bits and in pack them into unsigned saturated chunks of dst_size bits.
Then chunks are concatenated resulting in a BV of len(args)*dst_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.