[文档]def__init__(self,man=None):SimStatePlugin.__init__(self)ifman:self._region_base=man._region_baseself._pos=man._posself._alloc_depth_map=man._alloc_depth_map.copy()else:self._region_base=None# It will be set later when self.state is setself._pos=0self._alloc_depth_map={}## Some constants## The size of each region, in bytesself._region_size=0x1000# The maximum allocation depthself._max_alloc_depth=20self._uc_alloc_depth={}
[文档]defassign(self,dst_addr_ast):""" Assign a new region for under-constrained symbolic execution. :param dst_addr_ast: the symbolic AST which address of the new allocated region will be assigned to. :return: as ast of memory address that points to a new region """dst_uc_alloc_depth=self._uc_alloc_depth[dst_addr_ast]ifdst_uc_alloc_depth>self._max_alloc_depth:raiseSimUCManagerAllocationError(f"Current allocation depth {dst_uc_alloc_depth} is greater than the cap ({self._max_alloc_depth})")abs_addr=self._region_base+self._posptr=claripy.BVV(abs_addr,self.state.arch.bits)self._pos+=self._region_sizeself._alloc_depth_map[(abs_addr-self._region_base)//self._region_size]=dst_uc_alloc_depthl.debug("Assigned new memory region %s",ptr)returnptr
[文档]defis_bounded(self,ast):""" 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 """returnlen(ast.variables.intersection(self.state.solver._solver.variables))!=0