我成功地找到了如何使用angr运行程序,首先从内核转储(请参阅如何在加载elfcore后端后使用angr运行程序?)定义的状态开始,但现在我想知道:
如何在程序的SimulationState?中使用malloc内存?
我正在运行程序的起始状态是一个函数的开始,它有一个指针和一个长度。我希望能够以任意长度更新malloc内存,并将这个指针(和适当的长度)传递到函数中。
我发现有一个插件类,angr.state_plugins.heap.heap_libc.SimHeapLibc (文档),它有一个malloc方法,但是我如何使用这个插件,它实际上是我需要的吗?
发布于 2019-12-03 15:59:27
好吧,想清楚了。
首先,您需要的插件类是angr.state_plugins.heap.heap_ptmalloc.SimHeapPTMalloc。原来angr.state_plugins.heap.heap_libc.SimHeapLibc只是基类。
然后,用例变成:
simstate = angr.factory.AngrObjectFactory(proj).blank_state()
# IMPORTANT NOTE: you need to register the plugin with the name heap or it will break
simstate.register_plugin("heap", angr.state_plugins.heap.heap_ptmalloc.SimHeapPTMalloc())
# Voila, malloc and use arbitrary amounts of memory in the simulation space.
ptr = self.simstate.heap.malloc(data_len)
simstate.memory.store(ptr, simstate.solver.BVV(data_bytes, data_len*8))https://stackoverflow.com/questions/59142699
复制相似问题