How to detect that the app is running on a jailbroken device? [duplicate]
You can detect through code that if the app is running on a jail broken device or not. Through that way you can pop up an alert and close the app. You can do whatever you want to do. Here is a tutorial for it:
http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html
and here is a Stack Overflow post:
How do I detect that an iOS app is running on a jailbroken phone?
Also, if you want a complete solution, you can see in tapjoy sdk code. They are detecting jailbroken iPhone. Here is tapjoy URL https://www.tapjoy.com/
Check for these paths
+ (BOOL)isJailBroken {#ifdef TARGET_IPHONE_SIMULATOR return NO;#endif NSArray *paths = @[@"/bin/bash", @"/usr/sbin/sshd", @"/etc/apt", @"/private/var/lib/apt/", @"/Applications/Cydia.app", ]; for (NSString *path in paths) { if ([self fileExistsAtPath:path]) { return YES; } } return NO;}+ (BOOL)fileExistsAtPath:(NSString *)path { FILE *pFile; pFile = fopen([path cStringUsingEncoding:[NSString defaultCStringEncoding]], "r"); if (pFile == NULL) { return NO; } else fclose(pFile); return YES;}
Additionally, you can take a look https://github.com/OneSignal/OneSignal-iOS-SDK/blob/master/iOS_SDK/OneSignalSDK/Source/OneSignalJailbreakDetection.m
Try to find a file which cydia or jailbroken device create. Or try to write in a file outside the app's blackbox. If you succeed to do that, the device is compromised/jailbroken :)
- (BOOL)jailbroken{ NSFileManager * fileManager = [NSFileManager defaultManager]; return [fileManager fileExistsAtPath:@"/private/var/lib/apt/"];}