0

In my app i need to check sometimes if the running device is a jailbreak device or not. This is the most complete method i have found:

BOOL Jail=NO;
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"] ||
   [[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] ||
   [[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"] ||
   [[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"] ||
   [[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"] ||
   [[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"] ||
   [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]])  {
  Jail= YES;
}

FILE *f = NULL ;
if ((f = fopen("/bin/bash", "r")) ||
   (f = fopen("/Applications/Cydia.app", "r")) ||
   (f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r")) ||
   (f = fopen("/usr/sbin/sshd", "r")) ||
   (f = fopen("/etc/apt", "r")))  {
  fclose(f);
  Jail= YES;
}
fclose(f);

NSError *error;
NSString *stringToBeWritten = @"This is a test.";
[stringToBeWritten writeToFile:@"/private/jailbreak.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error];
[[NSFileManager defaultManager] removeItemAtPath:@"/private/jailbreak.txt" error:nil];
if(error == nil)
{
  Jail= YES;
}

What i haven't found, it's a clear answer to the question: "Apple will approve this code?" , in guidelines i can read:

"Apps that read or write data outside its designated container area will be rejected".

However it's clear that i'm trying to write or read only to check if the device is jailbroken... So there's someone that have successfully submitted this code to apple?

user31929
  • 1,115
  • 20
  • 43
  • possible duplicate of [How do I detect that an iOS app is running on a jailbroken phone?](http://stackoverflow.com/questions/413242/how-do-i-detect-that-an-ios-app-is-running-on-a-jailbroken-phone) – thelaws Jul 07 '15 at 14:04
  • Read the comment to this answer: http://stackoverflow.com/a/26712383/329801 – thelaws Jul 07 '15 at 14:04
  • thank's i haven't read this... Anyway it's only a comment, of only one person and i don't know if that user have really submit the code or if he only suppose that the code will be accepted – user31929 Jul 07 '15 at 14:14
  • 1
    you should use the _Receipt Validation_ procedure instead. you can find more information about that on the official [Apple Documentation](https://developer.apple.com/library/prerelease/ios/releasenotes/General/ValidateAppStoreReceipt/Introduction.html#//apple_ref/doc/uid/TP40010573-CH105-SW1), and I would recommend watch the [WWDC video](https://developer.apple.com/videos/wwdc/2014/) as well – it is much better than reading files outside of your app's sandbox, which pretty much ends up with rejection. – holex Jul 07 '15 at 14:23
  • Did you app pass review? We are intersted in this too – Petr Nov 26 '15 at 15:51
  • the app is still under development – user31929 Nov 30 '15 at 08:03

2 Answers2

2

This is the code of a submitted app

BOOL bash = NO;

FILE *f = fopen("/bin/bash", "r");
if (f != NULL)
{
    bash = YES;
}
fclose(f);

return bash;

So, I believe your code will be accepted too

Leonardo
  • 1,740
  • 18
  • 27
0

Maybe.

Many developer's have been rejected for including jailbreak checking, and many have not. If you submit with a jailbreak check, you should NOT expect to be approved (although you may get through the review process this time).

Community
  • 1
  • 1
thelaws
  • 7,991
  • 6
  • 35
  • 54