iOS Class Hook Examples

So your looking for those examples I talked about in my last tutorial are you? Well here they are finally! By the way, if you haven’t already seen my last tutorial, Cydia Tweaks, it explains the process of how to begin making cydia tweaks and getting the required tools to do so.

“Delete any” app

Anyways, my first example is a simple app that allows you to “temporarily” delete any of the applications on the springboard including the ones that apple has included. The reason I say temporarily is because if you respring or reboot your device after deleting the apps then they reappear as if never deleted. This is also apparent for the deleting cydia and any other jailbreak apps installed. Although, this is merely an example to show you what’s possible as I found this method in only a few minutes browsing the springboard classes.

The methods you will be hooking are:

- (BOOL) isSystemApplication;
- (BOOL) isInternalApplication;

I found them in the SBApplication class along with a few other “is … application” methods that can be utilized as well. Here is how I started my project using terminal if you want to follow along.

$ $THEOS/bin/nic.pl
NIC 1.0 - New Instance Creator
------------------------------
[1.] iphone/application
[2.] iphone/library
[3.] iphone/preference_bundle
[4.] iphone/tool
[5.] iphone/tweak
Choose a Template (required): 5
Project Name (required): DeleteAny
Package Name: com.snoapps.deleteany
Author/Maintainer Name: Snoapps
MobileSubstrate Bundle filter: com.apple.springboard

Then, in my Tweak.xm, I edit it to look like this.

%hook SBApplication

- (BOOL)isSystemApplication {
return false;
}

- (BOOL)isInternalApplication {
return true;
}

%end

Basically what’s happening is when you press and hold an app icon on your springboard, it calls these methods to check if they are system “built in” apple apps or if they were downloaded from the App store. By returning false for isSystemApplication no matter what, no app on your springboard is considered “Apple built in”. You will need the springboard class-dump for this which is located in the directory: /System/Library/CoreServices/SpringBoard.app/SpringBoard, copy the class-dump to /opt/theos/include/springboard/ on your mac so the compiler can recognize the class you are hooking, if you do not know how to class-dump goto my previous tutorial, Cydia Tweaks. Now, to test it out go back to your terminal window and cd into your project directory, which for me would be:

$ cd deleteany

and type in the following:

$ sudo make
Password:
Making all for tweak DeleteAny...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak DeleteAny...
Stripping DeleteAny...
Signing DeleteAny...

After you enter your password, you will see it doing several things to compile your project. Now to move it to your iDevice for testing, you will need to edit your makefile and add the following line to the top of the file:

THEOS_DEVICE_IP = 192.168.1.82

Of course you replace the 192.168.1.82 with your idevice’s local ip address which can be found under Settings > Wifi > arrow next to your wifi > Ip Address. Save that file and go back to your terminal window.

Next, type in the terminal window

export THEOS_DEVICE_IP = [your device ip]

Now you can package your project by typing

$ sudo make package

Now to install it to your device type

$ sudo make install

It will ask you for the ssh password a bunch of times and the default for openssh is: alpine. If this process worked your idevice should respring and when you hold down a home screen app it should let you delete any of apples built in apps as well. One issue is that the calendar doesn’t show the date on the icon while this tweak is active. Also, if you respring the device, the apps you weren’t originally able to delete that you deleted will reappear because they weren’t actually deleted. This is because the apps you download from the app store are in a different folder so it doesn’t know what directories to delete when you remove their icon. All this is just to say that this app is mainly for looks and not functionality. Post your comments, questions or if you make any sweet tweaks in the comments below.

My next tutorial will be showing you how to make a tweak to password protect your applications that you don’t want that one annoying person getting into, or just to keeping your data protected for whatever reason. In the mean time, have fun hacking away!

2 thoughts on “iOS Class Hook Examples”

  1. I am so eager to see your next tutorial. Can you show me how to protect apps on my iPhone by writing a tweak. Thank you.

Leave a Reply to Micaiah Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>