def remove_breakpoint(self, address, **kwargs): l.debug("AvatarGDBConcreteTarget remove_breakpoint at %x " % (address)) res = self.target.remove_breakpoint(address, **kwargs) if res == -1: raise SimConcreteBreakpointError( "AvatarGDBConcreteTarget failed to set_breakpoint at %x" % (address))
def set_syscall_breakpoint(self, name, **kwargs): """ Inserts a breakpoint at a specified syscall :param str name: The name of a syscall to break at :param optional bool temporary: indicates one-off breakpoints :raise angr.errors.ConcreteBreakpointError: """ l.debug("ZelosConcreteTarget set_syscall_breakpoint at '%s' " % (name)) if name in self.syscall_fake_pcs: fake_pc = self.syscall_fake_pcs[name] else: fake_pc = self.syscall_fake_pc_idx self.syscall_fake_pc_idx += 1 self.syscall_fake_pcs[name] = fake_pc try: self.s.set_syscall_breakpoint(name, kwargs.get("temporary", False)) except Exception as e: msg = ( "ZelosConcreteTarget failed set_syscall_breakpoint '%s': %s" % (name, e) ) l.debug(msg) raise SimConcreteBreakpointError(msg) return fake_pc
def remove_breakpoint(self, address, **kwargs): l.debug("R2ConcreteTarget remove_breakpoint at %x " % (address)) self.r2.cmd('db-{}'.format(hex(address))) # Sanity check that breakpoint got removed if any(x for x in self.r2.cmdj('dbj') if x['addr'] == address): raise SimConcreteBreakpointError( "R2ConcreteTarget failed to remove_breakpoint at %x" % (address))
def remove_watchpoint(self,address, **kwargs): """Removes a watchpoint :param address: The name of a variable or an address to watch :raise angr.errors.ConcreteBreakpointError """ wn = self.jlink.watchpoint_find(address) if wn == 0: raise SimConcreteBreakpointError("Watchpoint does not exist!") self.jlink.watchpoint_clear(bn)
def remove_watchpoint(self, address, **kwargs): l.debug("ZelosConcreteTarget remove_watchpoint at %x " % (address)) try: address = "0x{0:x}".format(address) self.s.remove_watchpoint(address) except Exception as e: msg = ( "ZelosConcreteTarget failed to remove_watchpoint at %s: %s" % (address, e) ) l.debug(msg) raise SimConcreteBreakpointError(msg)
def set_watchpoint(self,address, **kwargs): """ Inserts a watchpoint :param address: The name of a variable or an address to watch :param optional bool write: Write watchpoint :param optional bool read: Read watchpoint :raise angr.errors.ConcreteBreakpointError """ l.debug("gdb target set_watchpoing at %x value", address) res = self.target.set_watchpoint(address, **kwargs) if res == -1: raise SimConcreteBreakpointError("AvatarGDBConcreteTarget failed to set_breakpoint at %x" % (address))
def remove_syscall_breakpoint(self, name, **kwargs): l.debug( "ZelosConcreteTarget remove_syscall_breakpoint at '%s' " % (name) ) try: self.s.remove_syscall_breakpoint(name) except Exception as e: msg = ( "ZelosConcreteTarget failed remove_syscall_breakpoint '%s': %s" % (name, e) ) l.debug(msg) raise SimConcreteBreakpointError(msg)
def set_watchpoint(self, address, **kwargs): """Inserts a watchpoint :param address: The name of a variable or an address to watch :param optional bool write: Write watchpoint :param optional bool read: Read watchpoint :raise angr.errors.ConcreteBreakpointError """ read = kwargs.pop('read', False) write = kwargs.pop('write', False) rw_str = '' if read: rw_str += 'r' if write: rw_str += 'w' if rw_str == '': error = 'R2ConcreteTarget set_watchpoint invalid watch requested for address {}. Must specify type of watchpoint.'.format( hex(address)) l.error(error) raise SimConcreteBreakpointError(error) if kwargs != {}: l.warn( 'R2ConcreteTarget set_watchpoint called with extra args "{}".'. format(kwargs)) l.debug("R2ConcreteTarget target set_watchpoing at %x value" % (address)) self.r2.cmd('dbw {address} {fmt}'.format(address=address, fmt=rw_str)) # Make sure it got set if not any(x for x in self.r2.cmdj('dbj') if x['addr'] == address and x['hw'] == True): raise SimConcreteBreakpointError( "R2ConcreteTarget failed to set_breakpoint at %x" % (address))
def set_watchpoint(self,address, **kwargs): """Inserts a watchpoint :param address: The name of a variable or an address to watch :param optional bool write: Write watchpoint :param optional bool read: Read watchpoint :raise angr.errors.ConcreteBreakpointError """ read = kwargs.pop('read', False) write = kwargs.pop('write', False) try: self.jlink.watchpoint_set(address, read=read, write=write) except pylink.JLinkException: l.exception("Error setting watchpoint at %#08x", address) raise SimConcreteBreakpointError()
def set_breakpoint(self, address, **kwargs): """Inserts a breakpoint :param optional bool hardware: Hardware breakpoint :param optional bool temporary: Tempory breakpoint :param optional str regex: If set, inserts breakpoints matching the regex :param optional str condition: If set, inserts a breakpoint with the condition :param optional int ignore_count: Amount of times the bp should be ignored :param optional int thread: Thread cno in which this breakpoints should be added :raise angr.errors.ConcreteBreakpointError """ try: self.jlink.breakpoint_set(address) except pylink.JLinkException: l.exception("Error setting breakpoint at %#08x", address) raise SimConcreteBreakpointError()
def set_breakpoint(self,address, **kwargs): """ Inserts a breakpoint :param int address: The address at which to set the breakpoint :param optional bool hardware: Hardware breakpoint :param optional bool temporary: Tempory breakpoint :param optional str regex: If set, inserts breakpoints matching the regex :param optional str condition: If set, inserts a breakpoint with the condition :param optional int ignore_count: Amount of times the bp should be ignored :param optional int thread: Thread cno in which this breakpoints should be added :raise angr.errors.ConcreteBreakpointError: """ l.debug("AvatarGDBConcreteTarget set_breakpoint at %x "%(address)) res = self.target.set_breakpoint(address, **kwargs) if res == -1: raise SimConcreteBreakpointError("AvatarGDBConcreteTarget failed to set_breakpoint at %x" % (address))
def set_breakpoint(self, address, **kwargs): """ Inserts a breakpoint :param int address: The address at which to set the breakpoint :param optional bool hardware: Hardware breakpoint :param optional bool temporary: Tempory breakpoint :raise angr.errors.ConcreteBreakpointError: """ l.debug("ZelosConcreteTarget set_breakpoint at %x " % (address)) try: address = "0x{0:x}".format(address) self.s.set_breakpoint(address, kwargs.get("temporary", False)) except Exception as e: msg = "ZelosConcreteTarget failed to set_breakpoint at %s: %s" % ( address, e, ) l.debug(msg) raise SimConcreteBreakpointError(msg)
def set_watchpoint(self, address, **kwargs): """ Inserts a watchpoint :param address: The name of a variable or an address to watch :param optional bool write: Write watchpoint :param optional bool read: Read watchpoint :raise angr.errors.ConcreteBreakpointError: """ l.debug("ZelosConcreteTarget set_watchpoint at %x " % (address)) try: address = "0x{0:x}".format(address) self.s.set_watchpoint( address, kwargs.get("read", True), kwargs.get("write", True) ) except Exception as e: msg = "ZelosConcreteTarget failed to set_watchpoint at %s: %s" % ( address, e, ) l.debug(msg) raise SimConcreteBreakpointError(msg)
def set_breakpoint(self, address, **kwargs): """Inserts a breakpoint :param optional bool hardware: Hardware breakpoint :param optional bool temporary: Tempory breakpoint :param optional str regex: If set, inserts breakpoints matching the regex :param optional str condition: If set, inserts a breakpoint with the condition :param optional int ignore_count: Amount of times the bp should be ignored :param optional int thread: Thread cno in which this breakpoints should be added :raise angr.errors.ConcreteBreakpointError """ if kwargs != {}: l.warn( 'R2ConcreteTarget set_breakpoint called with extra args "{}". Currently, R2 is not handling these and will set breakpoint as normal software breakpoint.' .format(kwargs)) l.debug("R2ConcreteTarget set_breakpoint at %x " % (address)) self.r2.cmd('db {}'.format(hex(address))) # Sanity check that breakpoint actually got set if not any(x for x in self.r2.cmdj('dbj') if x['addr'] == address): raise SimConcreteBreakpointError( "R2ConcreteTarget failed to set_breakpoint at %x" % (address))
def stop(self): self.jlink.halt() if not self.jlink.halted(): raise SimConcreteBreakpointError("Failed to halt target!")
def remove_breakpoint(self, address, **kwargs): bn = self.jlink.breakpoint_find(address) if bn == 0: raise SimConcreteBreakpointError("Breakpoint does not exist!") self.jlink.breakpoint_clear(bn)