frida hook 原生非导出函数

2023-12-04

我出于学习目的逆向这个 Android 应用程序,该应用程序在本机层上实现了所有有趣的功能,因此我在 Arm Android Studio 映像上运行该应用程序并逆向共享库。因此该应用程序正在使用 ghidra 进行调用我设法将共享对象反编译成c,我发现了很多互相调用的函数,而且我还发现了尊重jni命名约定的函数

我可以成功挂钩任何上述导出,但是当我尝试挂钩以下函数时,我得到一个未找到的导出,如何挂钩这些本机函数?


我假设你正在使用弗里达的方法Module.findExportByName。这种方式仅适用于导出的函数。然而,您发布的 Ghidra 屏幕截图中可见的方法似乎是一个甚至没有名称的内部函数。

显示的名称如FUN_002d5044由 Ghidra 生成,因为该函数没有名称。它的基本意思是“地址 0x002d5044 处的未命名函数”。

Note that the address shown in Ghidra may include also a fixed base address (named Image Base - to see it go to Window -> Memory map -> Set Image Base Ghidra Image Base "house" icon). If the Image base is not 0 you have to substract this values from the shown address to get the address you can use for hooking.

您应该能够通过使用未命名函数的地址和实现它的模块的基地址直接挂钩它。

您只需插入正确的moduleName在下面的代码中:

const ghidraImageBase = 0x00040000; // example value get the real value in Ghidra from Window -> Memory map -> Set Image Base
const moduleName = "insert module name here";
const moduleBaseAddress = Module.findBaseAddress(moduleName);
const functionRealAddress = moduleBaseAddress.add(0x002d5044 - ghidraImageBase);
Interceptor.attach(functionRealAddress, {
                   onEnter: function(args) {
                       ...
                   }
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

frida hook 原生非导出函数 的相关文章

随机推荐