Detect if iOS app hacked

Eugene Trapeznikov picture Eugene Trapeznikov · Jul 23, 2012 · Viewed 6.9k times · Source

My friend got a jailbroken iPad. When he installed Business Model Generation App from Installous and tried to use it, the application showed a UIAlertView with the following message: Hacked Version

Does anybody know how to do that?

I have 2 ideas:

  1. If there is some set flag when you download app from the App Store, then you can use this flag: if flag = NO, you show the UIAlertView.
  2. Something with a server (but in this case, you should know all device IDs and who installed your application from the App Store).

Am I right? How can I implement this feature?

Answer

Eugene Trapeznikov picture Eugene Trapeznikov · Jul 24, 2012

You can detect two files: SC_Info and iTunesMetadata.​plist.

If you can't find them, then your app was pirated: these files are installed after downloading from the App Store.

This is the code to check:

NSString * bundlePath = [ [NSBundle mainBundle] bundlePath ];
if ( ! [ [NSFileManager defaultManager] fileExistsAtPath: ( @"%@/SC_Info", bundlePath ) ] )
{
    // jailbroken
}
if ( ! [ [NSFileManager defaultManager] fileExistsAtPath: ( @"%@/iTunesMetadata.​plist", bundlePath ) ] )
{
    // jailbroken
}