// check for some files that will exist on most jailbroken devices if ([fileManager fileExistsAtPath:@"/Applications/Cydia.app"] || [fileManager fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] || [fileManager fileExistsAtPath:@"/bin/bash"] || [fileManager fileExistsAtPath:@"/usr/sbin/sshd"] || [fileManager fileExistsAtPath:@"/etc/apt"]) { return YES; }
// check if we can write to private directories BOOL ok = [@"test" writeToFile:@"/private/jailbreak.txt.fiekaoi39fkd39akld" atomically:YES encoding:NSUTF8StringEncoding error:nil]; if (ok) { [fileManager removeItemAtPath:@"/private/jailbreak.txt.fiekaoi39fkd39akld" error:nil]; return YES; }
// check if the device can open cydia urls if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]){ return YES; }
{
#if TARGET_IPHONE_SIMULATOR
return NO;
#else
NSFileManager* fileManager = [NSFileManager defaultManager];
// check for some files that will exist on most jailbroken devices
if ([fileManager fileExistsAtPath:@"/Applications/Cydia.app"] ||
[fileManager fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] ||
[fileManager fileExistsAtPath:@"/bin/bash"] ||
[fileManager fileExistsAtPath:@"/usr/sbin/sshd"] ||
[fileManager fileExistsAtPath:@"/etc/apt"]) {
return YES;
}
// check if we can write to private directories
BOOL ok = [@"test" writeToFile:@"/private/jailbreak.txt.fiekaoi39fkd39akld" atomically:YES encoding:NSUTF8StringEncoding error:nil];
if (ok) {
[fileManager removeItemAtPath:@"/private/jailbreak.txt.fiekaoi39fkd39akld" error:nil];
return YES;
}
// check if the device can open cydia urls
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]){
return YES;
}
return NO;
#endif
}