Reputation: 41
I tried to inject my own library into an iOS binary(ipa) file. But I was not able to do it. This question may have suggestions in this site, but there is no proper solution. I already tried implementing some of the solutions or suggestions mentioned in the below links,
Add load command to mach-o binary
Inject dynamic library into enterprise app (ipa)
I want to know the flow of execution of an IPA file
http://coscolla.net/injecting-code-to-a-ipa/
I tried the to insert a load command of a library as per documentation mentioned in optool. which actually expects run time arguments. So I included the below arguments under Arguments section of Xcode,
install -c -p '/Users/raj/Desktop/Swizzling/libSwizzling.a' -t '/Users/raj/Documents/Builds/temp/Welcome.ipa' -o= '/Users/raj/Documents/Builds/temp/modified.ipa'
But it is not working. Even tried some other simple command and same result. If any one successfully used optool and its commands can help me out.
dyci-main is a code injection tool through which we can not add or insert library. This will be helpful for adding or modifying some logics or debugging purpose. Apart from that we can not do anything I hope. If any body having an idea to insert load command is greatly appreciated.
injecting-code-to-a-ipa is having some sort of solution but it is not clear. Even if you follow each and every steps you can't make it success. The main confusing part is some command load instruction we must execute as per screenshot and have to save as dynamic library. Which is the input file to execute commands? If you are able to make it successful, please let me know.
Unfortunately I was not able to make it working state. I really appreciate a person who really gives a clear and proper or working solution to this problem.
Thanks in advance.
Upvotes: 4
Views: 3890
Reputation: 128
how to use optool?
optool install -c load -p "@executable_path/RedEnvelop.dylib" -t WeChat
WeChat can load RedEnvelop.dylib
optool uninstall -p "@executable_path/RedEnvelop.dylib" -t WeChat
find dylib path you can use otool
to fint it:
otool -L WeChat
Upvotes: 3
Reputation: 11
I have used OpTool and it worked for me. I was more interested to insert load command for dynamic library and below is command line arguments i have setup. install -c -p -t ex. install -c load -p "@executable_path/LibraryName.dylib" -t "/Users/xxx/AppName.app/AppName"
-load : It is variable we have to give to insert LC_LOAD_DYLIB -payload : it should be always in format of "@executable_path/name of Library.dylib" since we will be copy pasting .dylib file into myapp.app directory. - target : here need to mention the full path of executable binary. which will be contained in myapp.app directory
The modified binary executable will be generated at same place and will be replaced.
One more thing is after this need to re-sign the ipa follow below url for the same. Re-sign IPA (iPhone)
Upvotes: 1