示例#1
0
    def test_mmap_hack32(self):
        my_target = target.TargetPlatform.make_target_linux_32()
        my_ctypes = my_target.get_target_ctypes()
        my_utils = my_target.get_target_ctypes_utils()

        real_ctypes_long = my_ctypes.get_real_ctypes_member('c_ulong')
        fname = os.path.normpath(os.path.abspath(__file__))
        fin = file(fname)
        local_mmap_bytebuffer = mmap.mmap(
            fin.fileno(),
            1024,
            access=mmap.ACCESS_READ)
        fin.close()
        fin = None
        # yeap, that right, I'm stealing the pointer value. DEAL WITH IT.
        heapmap = struct.unpack('L', (real_ctypes_long).from_address(id(local_mmap_bytebuffer) +
                                                                     2 * (my_ctypes.sizeof(real_ctypes_long))))[0]
        log.debug('MMAP HACK: heapmap: 0x%0.8x' % (heapmap))
        maps = read_local_process_mappings()
        ret = [m for m in maps if heapmap in m]
        # heapmap is a pointer value in local memory
        self.assertEquals(len(ret), 1)
        # heapmap is a pointer value to this executable?
        self.assertEquals(ret[0].pathname, fname)

        self.assertIn('CTypesProxy-4:4:12', str(my_ctypes))
示例#2
0
 def setUpClass(cls):
     cls.memory_handler= process.read_local_process_mappings()
     cls.my_target = cls.memory_handler.get_target_platform()
     cls.my_model = model.Model(cls.memory_handler)
示例#3
0
 def setUpClass(cls):
     cls.memory_handler = process.read_local_process_mappings()
     cls.my_target = cls.memory_handler.get_target_platform()
     cls.my_model = model.Model(cls.memory_handler)