IDA python:从偏移量读取n个字节

逆向工程 艾达 Python
2021-07-06 16:48:06

在 IDA 中使用 python,我想创建一个部分文件转储。例如,我想将偏移量 X 的数据转储为 Y 的大小。我相信我可以通过使用idc.Dword函数来做到这一点

offset = X
res = []
while offset < offset + Y:
    res.append(idc.Dword(offset))
    offset += 4
return res

有没有办法在不手动读取每个地址的情况下实现这一目标?

1个回答

idaapi.get_many_bytes 做到了:

https://www.hex-rays.com/products/ida/support/idapython_docs/ida_bytes-module.html#get_many_bytes

更新较新版本:

Python>get_bytes.__doc__
Return the specified number of bytes of the program
    @param ea: linear address
    @param size: size of buffer in normal 8-bit bytes
    @param use_dbg: if True, use debugger memory, otherwise just the database
    @return: None on failure
             otherwise a string containing the read bytes  

https://www.hex-rays.com/products/ida/support/idapython_docs/ida_bytes-module.html#get_bytes