How to use the angr.sim_state.SimState.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 / state_plugins / uc_manager.py View on Github external
"""
        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.state.solver._solver.variables)) != 0

    def set_state(self, state):
        super(SimUCManager, self).set_state(state)
        self._region_base = 0xd0 << (self.state.arch.bits - 8)


from angr.sim_state import SimState
SimState.register_default('uc_manager', SimUCManager)
github angr / angr / angr / state_plugins / solver.py View on Github external
return self._claripy_simplify(e)

    @timed_function
    @ast_stripping_decorator
    @error_converter
    def _claripy_simplify(self, *args): #pylint:disable=no-self-use
        return claripy.simplify(args[0])

    def variables(self, e): #pylint:disable=no-self-use
        """
        Returns the symbolic variables present in the AST of `e`.
        """
        return e.variables

from angr.sim_state import SimState
SimState.register_default('solver', SimSolver)

from .. import sim_options as o
from .inspect import BP_AFTER
from ..errors import SimValueError, SimUnsatError, SimSolverModeError, SimSolverOptionError
github angr / angr / angr / state_plugins / scratch.py View on Github external
return False

    def clear(self):
        s = self.state
        j = self.jumpkind
        self.__init__()
        self.state = s
        self.jumpkind = j # preserve jumpkind - "what is the previous jumpkind" is an important question sometimes

from .sim_action import SimActionObject, SimActionData
from ..errors import SimValueError
from .. import sim_options as o
from .inspect import BP_AFTER, BP_BEFORE

from angr.sim_state import SimState
SimState.register_default('scratch', SimStateScratch)
github angr / angr / angr / state_plugins / view.py View on Github external
def __getattr__(self, k):
        assert k != '_view'
        return self._view._deeper(ty=SimMemView.types['struct ' + k].with_arch(self._view.state.arch))

    def __setattr__(self, k, v):
        if k == '_view':
            object.__setattr__(self, k, v)
        else:
            self.__getattr__(k).store(v)

from ..sim_type import ALL_TYPES, SimTypeFixedSizeArray, SimTypePointer
SimMemView.types = ALL_TYPES # identity purposefully here


from angr.sim_state import SimState
SimState.register_default('mem', SimMemView)
SimState.register_default('regs', SimRegNameView)
github angr / angr / angr / state_plugins / abstract_memory.py View on Github external
return self.regions[address_wrapper.region].was_written_to(address_wrapper.address)

        return False

    def dbg_print(self):
        """
        Print out debugging information
        """
        for region_id, region in self.regions.items():
            print("Region [%s]:" % region_id)
            region.dbg_print(indent=2)


from ..sim_state import SimState
SimState.register_default('abs_memory', SimAbstractMemory)
github angr / angr / angr / state_plugins / plugin.py View on Github external
def register_default(cls, name, xtr=None):
        if cls is SimStatePlugin:
            if once('simstateplugin_register_default deprecation'):
                l.critical("SimStatePlugin.register_default(name, cls) is deprecated, please use SimState.register_default(name)")

            from angr.sim_state import SimState
            SimState.register_default(name, xtr)

        else:
            if xtr is cls:
                if once('simstateplugin_register_default deprecation case 2'):
                    l.critical("SimStatePlugin.register_default(name, cls) is deprecated, please use cls.register_default(name)")
                xtr = None

            from angr.sim_state import SimState
            SimState.register_default(name, cls, xtr if xtr is not None else 'default')
github angr / angr / angr / state_plugins / gdb.py View on Github external
def _write(self, addr, data):
        self.state.memory.store(addr, data)

    @staticmethod
    def _to_bvv(data):
        sz = len(data)
        num = int(binascii.hexlify(data), 16)
        return claripy.BVV(num, sz)

    @SimStatePlugin.memo
    def copy(self, memo): # pylint: disable=unused-argument
        return GDB()


from angr.sim_state import SimState
SimState.register_default('gdb', GDB)
github angr / angr / angr / state_plugins / symbolic_memory.py View on Github external
# Register state options
SimStateOptions.register_option("symbolic_ip_max_targets", int,
                                default=256,
                                description="The maximum number of concrete addresses a symbolic instruction pointer "
                                            "can be concretized to."
                                )
SimStateOptions.register_option("jumptable_symbolic_ip_max_targets", int,
                                default=16384,
                                description="The maximum number of concrete addresses a symbolic instruction pointer "
                                            "can be concretized to if it is part of a jump table."
                                )


from angr.sim_state import SimState
SimState.register_default('sym_memory', SimSymbolicMemory)

from ..errors import SimUnsatError, SimMemoryError, SimMemoryLimitError, SimMemoryAddressError, SimMergeError
from .. import sim_options as options
from .inspect import BP_AFTER, BP_BEFORE
from .. import concretization_strategies
github angr / angr / angr / state_plugins / callstack.py View on Github external
if action == 'push' and self.callframe is None:
            raise AngrError('callframe must be specified when action is "push".')

        elif action == 'pop' and self.callframe is not None:
            raise AngrError('callframe must not be specified when action is "pop".')

    def __repr__(self):
        if self.action == 'push':
            return "" % self.callframe
        else: # pop
            return "" % self.ret_site_addr


from angr.sim_state import SimState
SimState.register_default('callstack', CallStack)