Created
January 26, 2015 19:11
-
-
Save imranansari/70c7ed23efa418f2e8ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| +(BOOL)isJailbroken{ | |
| #if !(TARGET_IPHONE_SIMULATOR) | |
| if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]){ | |
| return YES; | |
| }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]){ | |
| return YES; | |
| }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"]){ | |
| return YES; | |
| }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"]){ | |
| return YES; | |
| }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"]){ | |
| return YES; | |
| }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"]){ | |
| return YES; | |
| } | |
| if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]){ | |
| return YES; | |
| } | |
| FILE *f = fopen("/bin/bash", "r"); | |
| if (f != NULL) { | |
| fclose(f); | |
| return YES; | |
| } | |
| fclose(f); | |
| f = fopen("/Applications/Cydia.app", "r"); | |
| if (f != NULL) { | |
| fclose(f); | |
| return YES; | |
| } | |
| fclose(f); | |
| f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r"); | |
| if (f != NULL) { | |
| fclose(f); | |
| return YES; | |
| } | |
| fclose(f); | |
| f = fopen("/usr/sbin/sshd", "r"); | |
| if (f != NULL) { | |
| fclose(f); | |
| return YES; | |
| } | |
| fclose(f); | |
| f = fopen("/etc/apt", "r"); | |
| if (f != NULL) { | |
| fclose(f); | |
| return 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){ | |
| return YES; | |
| } | |
| #endif | |
| //All checks have failed. Most probably, the device is not jailbroken | |
| return NO; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment