def read_memory(self, address, nbytes, **kwargs): """ Reading from memory of the target :param int address: The address to read from :param int nbytes: The amount number of bytes to read :return: The memory read :rtype: str :raise angr.errors.SimMemoryError """ LOGGER.debug("RevengeConcreteTarget read_memory at %x ", address) # Check if it's mapped if self._process.memory.maps[address] is None: error = "RevengeConcreteTarget can't read_memory at address {address}. Page is not mapped.".format( address=hex(address)) LOGGER.error(error) raise SimConcreteMemoryError(error) try: out = self._process.memory[address:address + nbytes].bytes except Exception as e: error = "RevengeConcreteTarget can't read_memory at address {address}: {e}".format( address=hex(address), e=e) LOGGER.error(error) raise SimConcreteMemoryError(error) if out is None: error = "RevengeConcreteTarget can't read_memory at address {address}".format( address=hex(address)) LOGGER.error(error) raise SimConcreteMemoryError(error) return out
def write_memory(self,address, value, **kwargs): # l.debug("AvatarGDBConcreteTarget write_memory at %x value %s " %(address, value.encode("hex"))) try: res = self.target.write_memory(address, 1, value, raw=True) if not res: l.warning("AvatarGDBConcreteTarget failed write_memory at %x value %s" % (address,value)) raise SimConcreteMemoryError("AvatarGDBConcreteTarget failed write_memory to address %x" % (address)) except Exception as e: l.warning("AvatarGDBConcreteTarget write_memory at %x value %s exception %s" % (address, value, e)) raise SimConcreteMemoryError("AvatarGDBConcreteTarget write_memory at %x value %s exception %s" % (address, str(value), e))
def write_memory(self, address, value, **kwargs): """ Writing to memory of the target :param int address: The address from where the memory-write should start :param bytes value: The actual value written to memory :raise angr.errors.ConcreteMemoryError """ assert type( value) is bytes, 'write_memory value is actually type {}'.format( type(value)) l.debug("R2ConcreteTarget write_memory at %x value %s " % (address, value)) try: self.r2.cmd("w6d {} @ {}".format( b64encode(value).decode(), hex(address))) """ if not res: l.warning("R2ConcreteTarget failed write_memory at %x value %s"%(address,value)) raise SimConcreteMemoryError("R2ConcreteTarget failed write_memory to address %x" % (address)) """ except Exception as e: l.warning( "R2ConcreteTarget write_memory at %x value %s exception %s" % (address, value, e)) raise SimConcreteMemoryError( "R2ConcreteTarget write_memory at %x value %s exception %s" % (address, str(value), e))
def read_memory(self, address, nbytes, **kwargs): try: l.debug("AvatarGDBConcreteTarget read_memory at %x "%(address)) page_end = (address | (self.page_size-1)) + 1 if address + nbytes > page_end: nbytes = page_end - address res = self.target.read_memory(address, 1, int(nbytes), raw=True) return res except Exception as e: l.debug("AvatarGDBConcreteTarget can't read_memory at address %x exception %s"%(address,e)) raise SimConcreteMemoryError("AvatarGDBConcreteTarget can't read_memory at address %x exception %s" % (address, e))
def write_memory(self,address, value, **kwargs): """ Writing to memory of the target :param int address: The address from where the memory-write should start :param bytes value: The actual value written to memory :raise angr.errors.ConcreteMemoryError """ assert type(value) is bytes, 'write_memory value is actually type {}'.format(type(value)) try: self.jlink.memory_write(address, value) except Exception as e: l.exception("JLinkConcreteTarget write_memory at %x value %s exception %s"%(address,value,e)) raise SimConcreteMemoryError("JLinkConcreteTarget write_memory at %x value %s exception %s" % (address, str(value), e))
def write_memory(self, address, value, **kwargs): """ Writing to memory of the target :param int address: The address to start writing :param str value: The actual value written to memory :raise angr.errors.ConcreteMemoryError: """ try: address = "0x{0:x}".format(address) self.s.write_memory(address, xmlrpc.client.Binary(value)) except Exception as e: msg = ( "ZelosConcreteTarget can't write_memory @ %s exception %s" % (address, e) ) l.debug(msg) raise SimConcreteMemoryError(msg)
def read_memory(self, address, nbytes, **kwargs): """ Reading from memory of the target :param int address: The address to read from :param int nbytes: The amount number of bytes to read :return: The memory read :rtype: str :raise angr.errors.SimMemoryError """ try: if self.cpu_running_event.is_set(): pylink.JLinkException() bs = self.jlink.memory_read(address, nbytes) except pylink.JLinkException: raise SimConcreteMemoryError(error) return bytes(bs)
def read_memory(self, address, nbytes, **kwargs): """ Reading from memory of the target :param int address: The address to read from :param int nbytes: The amount number of bytes to read :return: The memory read :rtype: str :raise angr.errors.SimMemoryError """ l.debug("R2ConcreteTarget read_memory at %x " % (address)) # Check if it's mapped if self.r2.cmd('dm.@{}'.format(hex(address))) == '': error = "R2ConcreteTarget can't read_memory at address {address}. Page is not mapped.".format( address=hex(address)) l.error(error) raise SimConcreteMemoryError(error) return bytes(self.r2.cmdj('pxj {} @ {}'.format(nbytes, hex(address))))
def read_memory(self, address, nbytes, **kwargs): """ Reading from memory of the target :param int address: The address to read from :param int nbytes: The amount number of bytes to read :return: The memory read :rtype: bytes :raise angr.errors.ConcreteMemoryError: """ try: address = "0x{0:x}".format(address) data = self.s.read_memory(address, nbytes) return data.data except Exception as e: msg = ( "ZelosConcreteTarget can't read_memory @ %s exception %s" % (address, e) ) l.debug(msg) raise SimConcreteMemoryError(msg)