如何在IDA中读取堆栈变量的内容?

时间:2016-11-22 05:19:01

标签: reverse-engineering ida

我注意到函数中的堆栈已经分配了一个char缓冲区。它是这样的:

.text:00401xxx Buffer= byte ptr -24h

我知道我可以通过以下方式在内存地址读取Dwords:

Dword(0x<address>)

但是,我如何对堆栈变量做同样的事情?具体来说,我希望能够读取整个字符缓冲区......

1 个答案:

答案 0 :(得分:0)

Yuo可以使用idc IDA模块,有许多有趣的功能。

如果您想要打印dword,这是正确的:
Dword(0x<address>)

对于上面建议的内存转储,您可以使用以下功能:

**GetManyBytes(ea, size, use_dbg=False)<br>**
Parameters:
        ea - linear address
        size - size of buffer in normal 8-bit bytes
        use_dbg - if True, use debugger memory, otherwise just the database

一个例子:

GetManyBytes(0x<address>, 50, True)

您可以调用函数运行时,也可以使用简单的脚本,如:

from idc import GetManyBytes
from struct import unpack

def simple_dump():
    arr = []
    for i in xrange(0, 2*SIZE_TO_DUMP, 2):
        bytes = GetManyBytes(0x<address>+i,2)
        arr.append(unpack("h", bytes)[0])
    return arr

def main():
    values = simple_dump()

您也可以使用IDA Hex-View窗口