Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call method from another app (Jailbreak iOS)

On a jailbroken iOS device, is it possible for one app to call a method from another app (an instance method, not a static one)? Another way of phrasing this: how can I get the instance of an app (assuming the app is running) so that I can call one of its methods?

Background: I am trying to call a function in the Music player app from a hooked method in the iPodUI Private Framework (see this post for more details).

This question has been asked for Android, but I didn't find anything for jailbreak iOS. If that's because I'm asking the wrong question and there's a different approach to take, I'm open to that.

like image 790
newenglander Avatar asked Oct 06 '13 20:10

newenglander


1 Answers

An easy and alternative way to achieve this is with cycript and system() call, however please BEWARE of the dangers of using system() before using it as it is potentially insecure (which is, to my opinion, not that much important on a jailbroken iOS where everything is pretty much unsafe)

let's say you have a method like [[SomeClass sharedInstance] methodToBeCalledExternally] that you want to call from some other process

you can save that call to a text file in /tmp/something.cy

then you inject that code externally by running:

cycript -p Music /tmp/something.cy

but if you need to do it programatically, and of course if the environment isn't sandboxed (I assume it isn't), then you can do:

system("cycript -p Music /tmp/something.cy")

this way you can execute arbitrary ObjC code in any process (in this case, the Music app), from your code.

finally, don't forget to remove the file /tmp/something.cy as you will no longer need it

like image 200
Eric Castro Avatar answered Nov 18 '22 11:11

Eric Castro