Пример #1
0
        if self.block_count == 0:
            return 1.0
        return 1 - (self.cumul_ratio / self.block_count)

    @angr.SimStatePlugin.memo
    def copy(self, memo):
        return DocPlugin(self.cumul_ratio, self.block_count)

    def merge(self, others, merge_conditions, common_ancestor=None):
        other_cumul_ratio = min([other.cumul_ratio for other in others])
        self.cumul_ratio = min(other_cumul_ratio, self.cumul_ratio)
        other_block_count = max([other.block_count for other in others])
        self.block_count = max(other_block_count, self.block_count)


SimState.register_default("doc", DocPlugin)


class DegreeOfConcreteness(ExplorationTechnique):
    def __init__(self, initial_state: SimState, max_states: int = 50):
        super().__init__()
        if not all([(ref in initial_state.options)
                    for ref in angr.sim_options.refs]):
            raise ValueError(
                "Degree of Concreteness requires initial_state to have options angr.sim_options.refs"
            )
        self.max_states = max_states
        self.states_to_prune = []

    def _calculate_doc(self, orig_addr: int, state: SimState):
        proj = state.project
Пример #2
0
        if self.last_node:
            if (self.last_node, node) in self.graph.edges:
                self.graph[self.last_node][node]["count"] += 1
            else:
                self.graph.add_edge(self.last_node, node, count=1)
        else:
            self.graph.add_node(node)
        self.last_node = node

    @angr.SimStatePlugin.memo
    def copy(self, memo):
        return HistoryGraph(deepcopy(self.graph), self.last_node)


SimState.register_default("history_graph", HistoryGraph)


class LoopLimiter(angr.ExplorationTechnique):
    """
    Limit the number of transitions for each edge. Implementation could be much better
    """
    def __init__(self, loop_bound: int = 20):
        super().__init__()
        self.loop_bound = loop_bound

    def step_state(self, simgr: SimulationManager, state: SimState, **kwargs):
        """
        Step the state forward and add node and/or edge to graph
        """
        stashes = simgr.step_state(state, **kwargs)