INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Generate a slice of the graph from the head node to the given frontier.
def slice_graph(graph, node, frontier, include_frontier=False): """ Generate a slice of the graph from the head node to the given frontier. :param networkx.DiGraph graph: The graph to work on. :param node: The starting node in the graph. :param frontier: A list of frontier nodes...
Translates an integer set list or function into a lambda that checks if state s current basic block matches some condition.
def condition_to_lambda(condition, default=False): """ Translates an integer, set, list or function into a lambda that checks if state's current basic block matches some condition. :param condition: An integer, set, list or lambda to convert to a lambda. :param default: The default return val...
Determines a persistent ID for an object. Does NOT do stores.
def _get_persistent_id(self, o): """ Determines a persistent ID for an object. Does NOT do stores. """ if type(o) in self.hash_dedup: oid = o.__class__.__name__ + "-" + str(hash(o)) self._object_cache[oid] = o return oid if any(isinsta...
Checks if the provided id is already in the vault.
def is_stored(self, i): """ Checks if the provided id is already in the vault. """ if i in self.stored: return True try: with self._read_context(i): return True except (AngrVaultError, EOFError): return False
Retrieves one object from the pickler with the provided id.
def load(self, id): #pylint:disable=redefined-builtin """ Retrieves one object from the pickler with the provided id. :param id: an ID to use """ l.debug("LOAD: %s", id) try: l.debug("... trying cached") return self._object_cache[id] excep...
Stores an object and returns its ID.
def store(self, o, id=None): #pylint:disable=redefined-builtin """ Stores an object and returns its ID. :param o: the object :param id: an ID to use """ actual_id = id or self._get_persistent_id(o) or "TMP-"+str(uuid.uuid4()) l.debug("STORE: %s %s", o, actual_id...
Returns a serialized string representing the object post - deduplication.
def dumps(self, o): """ Returns a serialized string representing the object, post-deduplication. :param o: the object """ f = io.BytesIO() VaultPickler(self, f).dump(o) f.seek(0) return f.read()
Deserializes a string representation of the object.
def loads(self, s): """ Deserializes a string representation of the object. :param s: the string """ f = io.BytesIO(s) return VaultUnpickler(self, f).load()
: param arch: the architecture: param reg_offset: Tries to find the name of a register given the offset in the registers.: return: The register name
def get_reg_name(arch, reg_offset): """ :param arch: the architecture :param reg_offset: Tries to find the name of a register given the offset in the registers. :return: The register name """ # todo does this make sense if reg_offset is None: return No...
converts an input state into a state with symbolic registers: return: the symbolic state
def _make_regs_symbolic(input_state, reg_list, project): """ converts an input state into a state with symbolic registers :return: the symbolic state """ state = input_state.copy() # overwrite all registers for reg in reg_list: state.registers.store(re...
: return: an initial state with a symbolic stack and good options for rop
def make_initial_state(project, stack_length): """ :return: an initial state with a symbolic stack and good options for rop """ initial_state = project.factory.blank_state( add_options={options.AVOID_MULTIVALUED_READS, options.AVOID_MULTIVALUED_WRITES, ...
converts an input state into a state with symbolic registers: return: the symbolic state
def make_symbolic_state(project, reg_list, stack_length=80): """ converts an input state into a state with symbolic registers :return: the symbolic state """ input_state = Identifier.make_initial_state(project, stack_length) symbolic_state = input_state.copy() # o...
Checks that the specified state options result in the same states over the next depth states.
def set_state_options(self, left_add_options=None, left_remove_options=None, right_add_options=None, right_remove_options=None): """ Checks that the specified state options result in the same states over the next `depth` states. """ s_right = self.project.factory.full_init_state( ...
Checks that the specified paths stay the same over the next depth states.
def set_states(self, left_state, right_state): """ Checks that the specified paths stay the same over the next `depth` states. """ simgr = self.project.factory.simulation_manager(right_state) simgr.stash(to_stash='right') simgr.active.append(left_state) simgr.sta...
Checks that a detected incongruency is not caused by translation backends having a different idea of what constitutes a basic block.
def _validate_incongruency(self): """ Checks that a detected incongruency is not caused by translation backends having a different idea of what constitutes a basic block. """ ot = self._throw try: self._throw = False l.debug("Validating incongrue...
Checks that the paths in the specified path group stay the same over the next depth bytes.
def run(self, depth=None): """ Checks that the paths in the specified path group stay the same over the next `depth` bytes. The path group should have a "left" and a "right" stash, each with a single path. """ #pg_history = [ ] if len(self.simgr.right) !=...
Compares two states for similarity.
def compare_states(self, sl, sr): """ Compares two states for similarity. """ joint_solver = claripy.Solver() # make sure the canonicalized constraints are the same n_map, n_counter, n_canon_constraint = claripy.And(*sr.solver.constraints).canonicalize() #pylint:disable=...
Checks state state to see if the breakpoint should fire.
def check(self, state, when): """ Checks state `state` to see if the breakpoint should fire. :param state: The state. :param when: Whether the check is happening before or after the event. :return: A boolean representing whether the checkpoint should fire. ""...
Trigger the breakpoint.
def fire(self, state): """ Trigger the breakpoint. :param state: The state. """ if self.action is None or self.action == BP_IPDB: import ipdb; ipdb.set_trace() #pylint:disable=F0401 elif self.action == BP_IPYTHON: import IPython shel...
Called from within SimuVEX when events happens. This function checks all breakpoints registered for that event and fires the ones whose conditions match.
def action(self, event_type, when, **kwargs): """ Called from within SimuVEX when events happens. This function checks all breakpoints registered for that event and fires the ones whose conditions match. """ l.debug("Event %s (%s) firing...", event_type, when) for k,v in ...
Creates and adds a breakpoint which would trigger on event_type. Additional arguments are passed to the: class: BP constructor.
def make_breakpoint(self, event_type, *args, **kwargs): """ Creates and adds a breakpoint which would trigger on `event_type`. Additional arguments are passed to the :class:`BP` constructor. :return: The created breakpoint, so that it can be removed later. """ bp = BP...
Adds a breakpoint which would trigger on event_type.
def add_breakpoint(self, event_type, bp): """ Adds a breakpoint which would trigger on `event_type`. :param event_type: The event type to trigger on :param bp: The breakpoint :return: The created breakpoint. """ if event_type not in event_typ...
Removes a breakpoint.
def remove_breakpoint(self, event_type, bp=None, filter_func=None): """ Removes a breakpoint. :param bp: The breakpoint to remove. :param filter_func: A filter function to specify whether each breakpoint should be removed or not. """ if bp is None and filter_func is No...
Remove previously stored attributes from this plugin instance to save memory. This method is supposed to be called by breakpoint implementors. A typical workflow looks like the following:
def downsize(self): """ Remove previously stored attributes from this plugin instance to save memory. This method is supposed to be called by breakpoint implementors. A typical workflow looks like the following : >>> # Add `attr0` and `attr1` to `self.state.inspect` >>> self.sta...
Given a state return the procedure corresponding to the current syscall. This procedure will have. syscall_number. display_name and. addr set.
def syscall(self, state, allow_unsupported=True): """ Given a state, return the procedure corresponding to the current syscall. This procedure will have .syscall_number, .display_name, and .addr set. :param state: The state to get the syscall number from :param all...
Return whether or not the given address corresponds to a syscall implementation.
def is_syscall_addr(self, addr): """ Return whether or not the given address corresponds to a syscall implementation. """ if self.kernel_base is None or addr < self.kernel_base: return False addr -= self.kernel_base if addr % self.syscall_addr_alignment != 0...
Get a syscall SimProcedure from an address.
def syscall_from_addr(self, addr, allow_unsupported=True): """ Get a syscall SimProcedure from an address. :param addr: The address to convert to a syscall SimProcedure :param allow_unsupported: Whether to return a dummy procedure for an unsupported syscall instead of raising an ...
Get a syscall SimProcedure from its number.
def syscall_from_number(self, number, allow_unsupported=True, abi=None): """ Get a syscall SimProcedure from its number. :param number: The syscall number :param allow_unsupported: Whether to return a "stub" syscall for unsupported numbers instead of throwing an error ...
Convert from a windows memory protection constant to an angr bitmask
def convert_prot(prot): """ Convert from a windows memory protection constant to an angr bitmask """ # https://msdn.microsoft.com/en-us/library/windows/desktop/aa366786(v=vs.85).aspx if prot & 0x10: return 4 if prot & 0x20: return 5 if prot & 0x40: return 7 if pro...
Make a hard copy of self.
def copy(self): """ Make a hard copy of `self`. :return: A new LiveDefinition instance. :rtype: angr.analyses.ddg.LiveDefinitions """ ld = LiveDefinitions() ld._memory_map = self._memory_map.copy() ld._register_map = self._register_map.copy() ld....
Add a new definition of variable.
def add_def(self, variable, location, size_threshold=32): """ Add a new definition of variable. :param SimVariable variable: The variable being defined. :param CodeLocation location: Location of the varaible being defined. :param int size_threshold: The maximum bytes to consider...
Add a collection of new definitions of a variable.
def add_defs(self, variable, locations, size_threshold=32): """ Add a collection of new definitions of a variable. :param SimVariable variable: The variable being defined. :param iterable locations: A collection of locations where the variable was defined. :param int size_thresh...
Add a new definition for variable and kill all previous definitions.
def kill_def(self, variable, location, size_threshold=32): """ Add a new definition for variable and kill all previous definitions. :param SimVariable variable: The variable to kill. :param CodeLocation location: The location where this variable is defined. :param int size_thres...
Find all definitions of the varaible
def lookup_defs(self, variable, size_threshold=32): """ Find all definitions of the varaible :param SimVariable variable: The variable to lookup for. :param int size_threshold: The maximum bytes to consider for the variable. For example, if the variable is 100 ...
Convert a ProgramVariable instance to a DDGViewItem object.
def _to_viewitem(self, prog_var): """ Convert a ProgramVariable instance to a DDGViewItem object. :param ProgramVariable prog_var: The ProgramVariable object to convert. :return: The converted DDGViewItem object. :rtype: DDGViewIt...
Get all definitions located at the current instruction address.
def definitions(self): """ Get all definitions located at the current instruction address. :return: A list of ProgramVariable instances. :rtype: list """ defs = set() if self._simplified: graph = self._ddg.simplified_data_graph else: ...
Pretty printing.
def pp(self): """ Pretty printing. """ # TODO: make it prettier for src, dst, data in self.graph.edges(data=True): print("%s <-- %s, %s" % (src, dst, data))
Get a dependency graph for the function func.
def function_dependency_graph(self, func): """ Get a dependency graph for the function `func`. :param func: The Function object in CFG.function_manager. :returns: A networkx.DiGraph instance. """ if self._function_data_dependencies is None: self._bu...
Get a subgraph from the data graph or the simplified data graph that starts from node pv.
def data_sub_graph(self, pv, simplified=True, killing_edges=False, excluding_types=None): """ Get a subgraph from the data graph or the simplified data graph that starts from node pv. :param ProgramVariable pv: The starting point of the subgraph. :param bool simplified: When True, the s...
Construct the data dependence graph.
def _construct(self): """ Construct the data dependence graph. We track the following types of dependence: - (Intra-IRSB) temporary variable dependencies - Register dependencies - Memory dependencies, although it's very limited. See below. We track the following...
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, statements): """ 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 tha...
This is a backward lookup in the previous defs. Note that as we are using VSA it is possible that variable is affected by several definitions.
def _def_lookup(self, variable): # pylint:disable=no-self-use """ This is a backward lookup in the previous defs. Note that, as we are using VSA, it is possible that `variable` is affected by several definitions. :param angr.analyses.ddg.LiveDefinitions live_defs: ...
Kill previous defs. addr_list is a list of normalized addresses.
def _kill(self, variable, code_loc): # pylint:disable=no-self-use """ 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 origina...
Get the size of a register.
def _get_register_size(self, reg_offset): """ Get the size of a register. :param int reg_offset: Offset of the register. :return: Size in bytes. :rtype: int """ # TODO: support registers that are not aligned if reg_offset in self.project.arch.register_na...
For memory actions get a list of addresses it operates on.
def _get_actual_addrs(action, state): """ For memory actions, get a list of addresses it operates on. :param SimAction action: The action object to work with. :return: A list of addresses that are accessed with that action. :rtype: list "...
Create a SimStackVariable or SimMemoryVariable based on action objects and its address.
def _create_memory_variable(self, action, addr, addrs): """ Create a SimStackVariable or SimMemoryVariable based on action objects and its address. :param SimAction action: The action to work with. :param int addr: The address of the memory variable in creation. :param l...
Add an edge in the data dependence graph.
def _data_graph_add_edge(self, src, dst, **edge_labels): """ Add an edge in the data dependence graph. :param ProgramVariable src: Source node. :param ProgramVariable dst: Destination node. :param edge_labels: All labels associated with the edge. :return: None ""...
Add an edge in the statement dependence graph from a program location src to another program location dst.
def _stmt_graph_add_edge(self, src, dst, **edge_labels): """ Add an edge in the statement dependence graph from a program location `src` to another program location `dst`. :param CodeLocation src: Source node. :param CodeLocation dst: Destination node. :param edge_labels: All la...
Add new annotations to edges in the statement dependence graph.
def _stmt_graph_annotate_edges(self, edges_to_annotate, **new_labels): """ Add new annotations to edges in the statement dependence graph. :param list edges_to_annotate: A list of edges to annotate. :param new_labels: New labels to be added to those edges. :returns: None ...
Simplify a data graph by removing all temp variable nodes on the graph.
def _simplify_data_graph(self, data_graph): # pylint:disable=no-self-use """ Simplify a data graph by removing all temp variable nodes on the graph. :param networkx.DiGraph data_graph: The data dependence graph to simplify. :return: The simplified graph. :rtype: networkx.MultiD...
Append a CFGNode and its successors into the work - list and respect the call - depth limit
def _worklist_append(self, node_wrapper, worklist, worklist_set): """ Append a CFGNode and its successors into the work-list, and respect the call-depth limit :param node_wrapper: The NodeWrapper instance to insert. :param worklist: The work-list, which is a list. :par...
Build dependency graphs for each function and save them in self. _function_data_dependencies.
def _build_function_dependency_graphs(self): """ Build dependency graphs for each function, and save them in self._function_data_dependencies. """ # This is a map between functions and its corresponding dependencies self._function_data_dependencies = defaultdict(networkx.DiGraph...
If we are not tracing into the function that are called in a real execution we should properly filter the defs to account for the behavior of the skipped function at this call site.
def _filter_defs_at_call_sites(self, defs): """ If we are not tracing into the function that are called in a real execution, we should properly filter the defs to account for the behavior of the skipped function at this call site. This function is a WIP. See TODOs inside. :para...
Find all definitions of the given variable.
def find_definitions(self, variable, location=None, simplified_graph=True): """ Find all definitions of the given variable. :param SimVariable variable: :param bool simplified_graph: True if you just want to search in the simplified graph instead of the normal ...
Find all consumers to the specified variable definition.
def find_consumers(self, var_def, simplified_graph=True): """ Find all consumers to the specified variable definition. :param ProgramVariable var_def: The variable definition. :param bool simplified_graph: True if we want to search in the simplified graph, False otherwise. :retu...
Find all killers to the specified variable definition.
def find_killers(self, var_def, simplified_graph=True): """ Find all killers to the specified variable definition. :param ProgramVariable var_def: The variable definition. :param bool simplified_graph: True if we want to search in the simplified graph, False otherwise. :return: ...
Find all sources to the specified variable definition.
def find_sources(self, var_def, simplified_graph=True): """ Find all sources to the specified variable definition. :param ProgramVariable var_def: The variable definition. :param bool simplified_graph: True if we want to search in the simplified graph, False otherwise. :return: ...
Allocates a new multi array in memory and returns the reference to the base.
def new_array(state, element_type, size, default_value_generator=None): """ Allocates a new multi array in memory and returns the reference to the base. """ size_bounded = SimSootExpr_NewMultiArray._bound_multi_array_size(state, size) # return the reference of the array base ...
Gets the minimum solution of an address.
def _min(self, memory, addr, **kwargs): """ Gets the minimum solution of an address. """ return memory.state.solver.min(addr, exact=kwargs.pop('exact', self._exact), **kwargs)
Gets the maximum solution of an address.
def _max(self, memory, addr, **kwargs): """ Gets the maximum solution of an address. """ return memory.state.solver.max(addr, exact=kwargs.pop('exact', self._exact), **kwargs)
Gets any solution of an address.
def _any(self, memory, addr, **kwargs): """ Gets any solution of an address. """ return memory.state.solver.eval(addr, exact=kwargs.pop('exact', self._exact), **kwargs)
Gets n solutions for an address.
def _eval(self, memory, addr, n, **kwargs): """ Gets n solutions for an address. """ return memory.state.solver.eval_upto(addr, n, exact=kwargs.pop('exact', self._exact), **kwargs)
Gets the ( min max ) range of solutions for an address.
def _range(self, memory, addr, **kwargs): """ Gets the (min, max) range of solutions for an address. """ return (self._min(memory, addr, **kwargs), self._max(memory, addr, **kwargs))
Concretizes the address into a list of values. If this strategy cannot handle this address returns None.
def concretize(self, memory, addr): """ Concretizes the address into a list of values. If this strategy cannot handle this address, returns None. """ if self._filter is None or self._filter(memory, addr): return self._concretize(memory, addr)
Given a local transition graph of a function find all merge points inside and then perform a quasi - topological sort of those merge points.
def find_merge_points(function_addr, function_endpoints, graph): # pylint:disable=unused-argument """ Given a local transition graph of a function, find all merge points inside, and then perform a quasi-topological sort of those merge points. A merge point might be one of the following...
Given a local transition graph of a function find all widening points inside.
def find_widening_points(function_addr, function_endpoints, graph): # pylint: disable=unused-argument """ Given a local transition graph of a function, find all widening points inside. Correctly choosing widening points is very important in order to not lose too much information during static ...
Sort a given set of nodes in reverse post ordering.
def reverse_post_order_sort_nodes(graph, nodes=None): """ Sort a given set of nodes in reverse post ordering. :param networkx.DiGraph graph: A local transition graph of a function. :param iterable nodes: A collection of nodes to sort. :return: A list of sorted nodes. :rt...
Sort a given set of nodes from a graph based on the following rules:
def quasi_topological_sort_nodes(graph, nodes=None): """ Sort a given set of nodes from a graph based on the following rules: # - if A -> B and not B -> A, then we have A < B # - if A -> B and B -> A, then the ordering is undefined Following the above rules gives us a quasi-top...
Append all nodes from a strongly connected component to a list of ordered nodes and ensure the topological order.
def _append_scc(graph, ordered_nodes, scc): """ Append all nodes from a strongly connected component to a list of ordered nodes and ensure the topological order. :param networkx.DiGraph graph: The graph where all nodes belong to. :param list ordered_nodes: Ordered nodes. ...
Mulpyplex across several stashes.
def mulpyplex(self, *stashes): """ Mulpyplex across several stashes. :param stashes: the stashes to mulpyplex :return: a mulpyplexed list of states from the stashes in question, in the specified order """ return mulpyplexer.MP(list(itertools.chain.from_iterable(self._st...
Make a copy of this simulation manager. Pass deep = True to copy all the states in it as well.
def copy(self, deep=False): # pylint: disable=arguments-differ """ Make a copy of this simulation manager. Pass ``deep=True`` to copy all the states in it as well. """ simgr = SimulationManager(self._project, stashes=self._copy_stashes(deep=deep), ...
Use an exploration technique with this SimulationManager.
def use_technique(self, tech): """ Use an exploration technique with this SimulationManager. Techniques can be found in :mod:`angr.exploration_techniques`. :param tech: An ExplorationTechnique object that contains code to modify this SimulationManager's behav...
Remove an exploration technique from a list of active techniques.
def remove_technique(self, tech): """ Remove an exploration technique from a list of active techniques. :param tech: An ExplorationTechnique object. :type tech: ExplorationTechnique """ if not isinstance(tech, ExplorationTechnique): raise SimulationMan...
Tick stash stash forward ( up to n times or until num_find states are found ) looking for condition find avoiding condition avoid. Stores found states into find_stash and avoided states into avoid_stash.
def explore(self, stash='active', n=None, find=None, avoid=None, find_stash='found', avoid_stash='avoid', cfg=None, num_find=1, **kwargs): """ Tick stash "stash" forward (up to "n" times or until "num_find" states are found), looking for condition "find", avoiding condition "avoi...
Run until the SimulationManager has reached a completed state according to the current exploration techniques. If no exploration techniques that define a completion state are being used run until there is nothing left to run.
def run(self, stash='active', n=None, until=None, **kwargs): """ Run until the SimulationManager has reached a completed state, according to the current exploration techniques. If no exploration techniques that define a completion state are being used, run until there is nothing left to ...
Returns whether or not this manager has reached a completed state.
def complete(self): """ Returns whether or not this manager has reached a "completed" state. """ if not self._techniques: return False if not any(tech._is_overriden('complete') for tech in self._techniques): return False return self.completion_mode...
Step a stash of states forward and categorize the successors appropriately.
def step(self, stash='active', n=None, selector_func=None, step_func=None, successor_func=None, until=None, filter_func=None, **run_args): """ Step a stash of states forward and categorize the successors appropriately. The parameters to this function allow you to control everything...
Don t use this function manually - it is meant to interface with exploration techniques.
def step_state(self, state, successor_func=None, **run_args): """ Don't use this function manually - it is meant to interface with exploration techniques. """ try: successors = self.successors(state, successor_func=successor_func, **run_args) stashes = {None: succ...
Don t use this function manually - it is meant to interface with exploration techniques.
def successors(self, state, successor_func=None, **run_args): """ Don't use this function manually - it is meant to interface with exploration techniques. """ if successor_func is not None: return successor_func(state, **run_args) return self._project.factory.successo...
Prune unsatisfiable states from a stash.
def prune(self, filter_func=None, from_stash='active', to_stash='pruned'): """ Prune unsatisfiable states from a stash. This function will move all unsatisfiable states in the given stash into a different stash. :param filter_func: Only prune states that match this filter. :par...
Move states from one stash to another.
def move(self, from_stash, to_stash, filter_func=None): """ Move states from one stash to another. :param from_stash: Take matching states from this stash. :param to_stash: Put matching states into this stash. :param filter_func: Stash states that match this filter. Should b...
Stash some states. This is an alias for move () with defaults for the stashes.
def stash(self, filter_func=None, from_stash='active', to_stash='stashed'): """ Stash some states. This is an alias for move(), with defaults for the stashes. :param filter_func: Stash states that match this filter. Should be a function that takes a state and returns...
Unstash some states. This is an alias for move () with defaults for the stashes.
def unstash(self, filter_func=None, to_stash='active', from_stash='stashed'): """ Unstash some states. This is an alias for move(), with defaults for the stashes. :param filter_func: Unstash states that match this filter. Should be a function that takes a state and r...
Drops states from a stash. This is an alias for move () with defaults for the stashes.
def drop(self, filter_func=None, stash='active'): """ Drops states from a stash. This is an alias for move(), with defaults for the stashes. :param filter_func: Drop states that match this filter. Should be a function that takes a state and returns True or False. (de...
Applies a given function to a given stash.
def apply(self, state_func=None, stash_func=None, stash='active', to_stash=None): """ Applies a given function to a given stash. :param state_func: A function to apply to every state. Should take a state and return a state. The returned state will take the place of ...
Split a stash of states into two stashes depending on the specified options.
def split(self, stash_splitter=None, stash_ranker=None, state_ranker=None, limit=8, from_stash='active', to_stash='stashed'): """ Split a stash of states into two stashes depending on the specified options. The stash from_stash will be split into two stashes depending on the other...
Merge the states in a given stash.
def merge(self, merge_func=None, merge_key=None, stash='active'): """ Merge the states in a given stash. :param stash: The stash (default: 'active') :param merge_func: If provided, instead of using state.merge, call this function with the states as the...
Merges a list of states.
def _merge_states(self, states): """ Merges a list of states. :param states: the states to merge :returns SimState: the resulting state """ if self._hierarchy: optimal, common_history, others = self._hierarchy.most_mergeable(states) else: ...
Launch a postmortem debug shell at the site of the error.
def debug(self): """ Launch a postmortem debug shell at the site of the error. """ try: __import__('ipdb').post_mortem(self.traceback) except ImportError: __import__('pdb').post_mortem(self.traceback)
Calculate the complement of self and other.
def complement(self, other): """ Calculate the complement of `self` and `other`. :param other: Another SimVariableSet instance. :return: The complement result. """ s = SimVariableSet() s.register_variables = self.register_variables - other.register_vari...
Get the CFGNode object on the control flow graph given an angr state.
def _get_cfg_node(cfg, state): """ Get the CFGNode object on the control flow graph given an angr state. :param angr.analyses.CFGEmulated cfg: An instance of CFGEmulated. :param angr.SimState state: The current state. :return: A CFGNode instance if the node exists,...
Perform a depth - first search on the given DiGraph with a limit on maximum steps.
def _dfs_edges(graph, source, max_steps=None): """ Perform a depth-first search on the given DiGraph, with a limit on maximum steps. :param networkx.DiGraph graph: The graph to traverse. :param Any source: The source to begin traversal. :param int max_steps: ...
Check if the specified address will be executed
def check(self, cfg, state, peek_blocks): """ Check if the specified address will be executed :param cfg: :param state: :param int peek_blocks: :return: :rtype: bool """ # Get the current CFGNode from the CFG node = self._get_cfg_node(cfg...
Check if the specified function will be reached with certain arguments.
def check(self, cfg, state, peek_blocks): """ Check if the specified function will be reached with certain arguments. :param cfg: :param state: :param peek_blocks: :return: """ # Get the current CFGNode node = self._get_cfg_node(cfg, state) ...
Check if the specific function is reached with certain arguments
def check_state(self, state): """ Check if the specific function is reached with certain arguments :param angr.SimState state: The state to check :return: True if the function is reached with certain arguments, False otherwise. :rtype: bool """ if state.addr == ...
Make sure all current basic block on each state shows up in the CFG. For blocks that are not in the CFG start CFG recovery from them with a maximum basic block depth of 100.
def _peek_forward(self, simgr): """ Make sure all current basic block on each state shows up in the CFG. For blocks that are not in the CFG, start CFG recovery from them with a maximum basic block depth of 100. :param simgr: :return: """ if self._cfg is None: ...
Load the last N deprioritized states will be extracted from the deprioritized stash and put to active stash. N is controlled by num_fallback_states.
def _load_fallback_states(self, pg): """ Load the last N deprioritized states will be extracted from the "deprioritized" stash and put to "active" stash. N is controlled by 'num_fallback_states'. :param SimulationManager pg: The simulation manager. :return: None """ ...
Categorize all states into two different groups: reaching the destination within the peek depth and not reaching the destination within the peek depth.
def _categorize_states(self, simgr): """ Categorize all states into two different groups: reaching the destination within the peek depth, and not reaching the destination within the peek depth. :param SimulationManager simgr: The simulation manager that contains states. All active st...
Detects if there is any xor operation in the function.
def has_xor(self): """ Detects if there is any xor operation in the function. :return: Tags """ def _has_xor(expr): return isinstance(expr, pyvex.IRExpr.Binop) and expr.op.startswith("Iop_Xor") found_xor = False for block in self._function.blocks: ...
Detects if there is any bitwise operation in the function.
def has_bitshifts(self): """ Detects if there is any bitwise operation in the function. :return: Tags. """ def _has_bitshifts(expr): if isinstance(expr, pyvex.IRExpr.Binop): return expr.op.startswith("Iop_Shl") or expr.op.startswith("Iop_Shr") \ ...