将 Mac 二进制文件加载为动态库
我正在使用没有源代码的二进制可执行文件进行一些逆向工程。在 Windows 上,我可以做的是使用 LoadLibrary 加载可执行文件 (EXE),就像它是 DLL 文件一样。如果加载的文件不可重新定位,我可以简单地重新定位加载器代码,为其他模块“腾出空间”。当我加载二进制文件时,我可以调用它的函数(当然,假设我在它们所在的位置),并执行其他操作。
有什么方法可以在 Mac 上做相同或类似的事情吗?我有一个 mach-o 可执行文件,我想加载它,因为它是一个动态库(DYLIB)。或者有什么方法可以将可执行文件转换为 DYLIB?可执行文件和 DYLIB 之间的真正区别是什么?
I am doing some reverse engineering with a binary executable without sources. On Windows what I can do is load an executable file (EXE) with LoadLibrary, just as it was a DLL file. If the loaded file is not relocatable I can simply relocate my loader code to "make space" for the other module. When I have the binary loaded, I can call it's functions (assuming I where where they are, of course), and do other stuff.
Is there some way to do the same or similar on Mac? I have a mach-o executable, and I'd like to load it as it was a dynamic library (DYLIB). Or is there some way to convert an executable into a DYLIB? What are the real differences between an executable and a DYLIB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以我做了一些实验,看到了这一点。文件“bin1.c”包含:
并且“bin2.c”是:
在我的Mac上,所有编译都很好并且确实加载了其他可执行文件,因为它是可加载库,并且我可以调用其他二进制文件中的主函数:
不确定不过,这是否有限制,以及是否可以使用不可重定位的二进制文件来完成。但这个例子表明,至少在某些情况下,这是可能的。
OK, so I did some experiments, and see this. File "bin1.c" contains:
and "bin2.c" is:
On my Mac, all compiles fine and indeed loads the other executable as it was a loadable library, and I can call the main function in the other binary:
Not sure though, whether there are limitations on this and if this can be done with non-relocatable binaries. But this example show that at least in some cases, it's possible.