我正忙于学习一个教程,其中作者使用DUMPBIN列出导出,使用OllyDbg获取导出函数的汇编代码。如果导出表RVA与反汇编中的真实地址不对应,我如何在完全反汇编中找到函数代码。
发布于 2009-03-03 06:49:57
RVA是可重定位的虚拟地址。要找到进程空间中的真实地址,您需要知道模块在进程中加载的基地址。将该基地址添加到RVA,您就得到了实际地址。我没有使用ollydbg,但是如果它没有提供它所附加到的进程中加载的模块的基址,我会感到惊讶。如果由于某种原因它没有提供这些信息,您可以通过使用sysinternal工具中的procexp.exe来获取它。
发布于 2009-03-01 13:06:31
设置堆栈框架的代码是函数的一个很好的指示器,至少对于用高级语言编写的程序来说是这样。
如果您知道用于生成有问题的代码的编译器,您应该能够找到要查找的内容。
示例
$ cat main.c
int main(int argc, char **argv) {
return 1;
}
$ gcc -m32 -S main.c
$ cat main.s
.file "main.c"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
movl $1, %eax
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (Debian 4.3.3-4) 4.3.3"
.section .note.GNU-stack,"",@progbits在我的示例中,movl %esp,%ebp指令是该设置代码的最后一条指令。
商业反汇编程序IDA Pro在自动查找函数方面做得很好,它的free-as-in-beer version可供下载。
发布于 2019-12-28 12:38:17
如果使用radare2,您可以在二进制(可能)中使用-AA标志来分析函数,然后使用afl命令列出所有函数。例如:
% r2 -AA hello
[Cannot analyze at 0x00400420g with sym. and entry0 (aa)
[x] Analyze all flags starting with sym. and entry0 (aa)
[Cannot analyze at 0x00400420ac)
[x] Analyze function calls (aac)
[x] Analyze len bytes of instructions for references (aar)
[x] Check for objc references
[x] Check for vtables
[x] Type matching analysis for all functions (aaft)
[x] Propagate noreturn information
[x] Use -AA or aaaa to perform additional experimental analysis.
[x] Finding function preludes
[x] Enable constraint types analysis for variables
-- Greetings, human.
[0x00400430]> afl
0x00400430 1 41 entry0
0x00400410 1 6 sym.imp.__libc_start_main
0x00400460 4 50 -> 41 sym.deregister_tm_clones
0x004004a0 4 58 -> 55 sym.register_tm_clones
0x004004e0 3 28 entry.fini0
0x00400500 4 38 -> 35 entry.init0
0x004005b0 1 2 sym.__libc_csu_fini
0x004005b4 1 9 sym._fini
0x00400540 4 101 sym.__libc_csu_init
0x00400526 1 21 main
0x00400400 1 6 sym.imp.puts
0x004003c8 3 26 sym._init
[0x00400430]>https://stackoverflow.com/questions/599762
复制相似问题