How to use the angr.analyses.AnalysesHub.register_default function in angr

To help you get started, we’ve selected a few angr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angr / angr / angr / analyses / decompiler / optimization_passes / stack_canary_simplifier.py View on Github external
return None

    def _calls_stack_chk_fail(self, node):

        for stmt in node.statements:
            if isinstance(stmt, ailment.Stmt.Call) and isinstance(stmt.target, ailment.Expr.Const):
                const_target = stmt.target.value
                if const_target in self.kb.functions:
                    func = self.kb.functions.function(addr=const_target)
                    if func.name == "__stack_chk_fail":
                        return True

        return False


AnalysesHub.register_default("StackCanarySimplifier", StackCanarySimplifier)
github angr / angr / angr / analyses / cdg.py View on Github external
for b1, b2 in loop_back_edges:
            # The edge between b1 and b2 is manually broken
            # The post dominator of b1 should be b2 (or not?)

            successors = list(self._pd_graph_successors(cfg, b1))

            if len(successors) == 0:
                if b2 in self._post_dom:
                    self._post_dom.add_edge(b1, b2)
                else:
                    _l.debug("%s is not in post dominator dict.", b2)


from angr.analyses import AnalysesHub
AnalysesHub.register_default('CDG', CDG)
github angr / angr / angr / analyses / decompiler / optimization_passes / base_ptr_save_simplifier.py View on Github external
for idx, stmt in enumerate(first_block.statements):
            if isinstance(stmt, ailment.Stmt.Store) \
                    and isinstance(stmt.addr, ailment.Expr.StackBaseOffset) \
                    and isinstance(stmt.data, ailment.Expr.Register) \
                    and stmt.data.reg_offset == self.project.arch.bp_offset \
                    and stmt.addr.offset < 0:
                return first_block, idx
            if isinstance(stmt, ailment.Stmt.Store) \
                    and isinstance(stmt.addr, ailment.Expr.StackBaseOffset) \
                    and isinstance(stmt.data, ailment.Expr.StackBaseOffset) \
                    and stmt.data.offset == 0 \
                    and stmt.addr.offset < 0:
                return first_block, idx


AnalysesHub.register_default('BasePointerSaveSimplifier',
                             BasePointerSaveSimplifier)
github angr / angr / angr / analyses / register_delta_tracker.py View on Github external
def _merge_states(self, node, *states):

        assert len(states) == 2
        try:
            return states[0].merge(states[1])
        except MergeException:
            _l.warning('Failed to merge stack pointer tracking states')
            self.abort()

        # return the first one. It's aborting anyway.
        return states[0]


from ..analyses import AnalysesHub
AnalysesHub.register_default('RegisterDeltaTracker', RegisterDeltaTracker)
github angr / angr / angr / analyses / dfg.py View on Github external
for e in stmt.expressions:
                        if e.tag == 'Iex_RdTmp':
                            dfg.add_edge(tmpsnodes[e.tmp], stmt_node)
                        else:
                            dfg.add_edge(e, stmt_node)

            for vtx in list(dfg.nodes()):
                if dfg.degree(vtx) == 0:
                    dfg.remove_node(vtx)

            if dfg.size() > 0:
                dfgs[node.addr] = dfg
        return dfgs

from angr.analyses import AnalysesHub
AnalysesHub.register_default('DFG', DFG)
github angr / angr / angr / analyses / decompiler / decompiler.py View on Github external
# recover regions
        ri = self.project.analyses.RegionIdentifier(self.func, graph=clinic.graph, kb=self.kb)

        # structure it
        rs = self.project.analyses.RecursiveStructurer(ri.region, kb=self.kb)

        # simplify it
        s = self.project.analyses.RegionSimplifier(rs.result, kb=self.kb)

        codegen = self.project.analyses.StructuredCodeGenerator(self.func, s.result, cfg=self._cfg, kb=self.kb)

        self.codegen = codegen


AnalysesHub.register_default('Decompiler', Decompiler)
github angr / angr / angr / analyses / vsa_ddg.py View on Github external
self.graph.add_edge(s_a, s_b, **edge_labels)
            self._new = True
            l.info("New edge: %s --> %s", s_a, s_b)

    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)
        return nodes

from angr.analyses import AnalysesHub
AnalysesHub.register_default('VSA_DDG', VSA_DDG)
github angr / angr / angr / analyses / static_hooker.py View on Github external
l.debug("Skipping %s at %#x, already hooked", func.name, func.rebased_addr)
                continue

            if lib.has_implementation(func.name):
                proc = lib.get(func.name, self.project.arch)
                self.results[func.rebased_addr] = proc
                if self.project.is_hooked(func.rebased_addr):
                    l.debug("Skipping %s at %#x, already hooked", func.name, func.rebased_addr)
                else:
                    self.project.hook(func.rebased_addr, proc)
                    l.info("Hooked %s at %#x", func.name, func.rebased_addr)
            else:
                l.debug("Failed to hook %s at %#x", func.name, func.rebased_addr)

from angr.analyses import AnalysesHub
AnalysesHub.register_default('StaticHooker', StaticHooker)
github angr / angr / angr / analyses / cfg / cfb.py View on Github external
_l.debug("Loading bytes from object %s, section %s, segmeng %s, addresss %#x.",
                                     obj, section, segment, next_addr)
                            bytes_ = self.project.loader.memory.load(next_addr, size)
                        except KeyError:
                            # The address does not exist
                            bytes_ = None
                    self.add_obj(end_addr,
                                 Unknown(end_addr, size, bytes_=bytes_, object_=obj, segment=segment, section=section)
                                 )
                addr = next_addr
            else:
                addr = max_addr


from angr.analyses import AnalysesHub
AnalysesHub.register_default('CFB', CFBlanket)
AnalysesHub.register_default('CFBlanket', CFBlanket)