How to insert a LC_LOAD_DYLIB command into a Mach-O binary or join a static library to an existing binary (IOS)

落爺英雄遲暮 提交于 2019-12-03 05:11:56

问题


This is the first time I am asking on stackoverflow and I am desperate.

My task is to load a dylib or join a static lib to an already existing executable for an IOS device.

I will be using the static void __attribute__((constructor)) initialize(void) to start the swizzling. This executable is for in house enterprise appstore so i do not need to go thru the apple appstore (since they will reject it).

The reason for this is to take an existing IPA from a customer and their signing keys and add a new functionality to their application without requiring a developer intervention.

There is one company doing that called nukona. You can watch the movie here: https://www.youtube.com/watch?feature=player_embedded&v=z9rrOB6lOxY

I can tell you that i tried to put LSEnvironment inside the plist file with a DYLD_INSERT_LIBRARIES but it turns out LSEnvironment does not seem to have any effect in the sandbox of an IOS application.

I also tried install_name_tool for changing one of the dependencies and replacing it with my dylib (which has that dependecy as well). It crashes without information why.

Obviously, if i add the dylib to a test application in XCode and recompile it works perfectly which is a given. However, this is something i cannot ask, for example, an administrator of a company. Rebuilding may deter customers of using this lib.

Here is a related link i found on stack overflow but for osx and i need it for IOS. How to insert a LC_LOAD_DYLIB command into a Mach-O binary (OSX)

The only thing i can think off is to edit the binary load commands some how, but i am not sure how and how to do it taking into account the relocation tables etc...

Any alternative is welcome.

Thank you for your time.


回答1:


I open-sourced optool which does exactly this (I haven't tested it on iOS but it should work. Open up an issue if you have problems)



来源:https://stackoverflow.com/questions/11018113/how-to-insert-a-lc-load-dylib-command-into-a-mach-o-binary-or-join-a-static-libr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!