我正忙着学习作者使用DUMPBIN列出导出的教程,以及OllyDbg来获取导出函数的汇编代码。考虑到导出表RVA与反汇编中的实际地址不对应,我如何在完全反汇编中找到函数代码。
答案 0 :(得分:3)
功能的一个非常好的指标,至少对于用高级语言编写的程序,是设置堆栈帧的代码。
如果您知道用于生成相关代码的编译器,您应该能够找到要查找的内容。
实施例
$ 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 指令是该设置代码的最后一条指令。
可以下载free-as-in-beer version的商业反汇编IDA Pro可以很好地自动查找功能。
答案 1 :(得分:3)
RVA是可重定位的虚拟地址。要在进程空间中查找实际地址,您需要知道进程中加载模块的基址。将该基地址添加到RVA,您就拥有了真实的地址。我没有使用过ollydbg,但是如果它没有为它附加的进程中加载的模块提供基地址,我会感到震惊。如果由于某种原因它不提供该信息,您可以使用sysinternal工具中的procexp.exe来获取它。
答案 2 :(得分:1)
如果使用radare2,则可以使用java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at GenFieldsConfigManagerTest.getRowCountForBPMTest(GenFieldsConfigManagerTest.java:345)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 23 more
标志以二进制(也许)形式分析函数,然后使用-AA
命令列出所有函数。例如:
afl
radare2 % 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]>
Cutter的Windows版本