Created
May 31, 2017 08:00
-
-
Save irshadpc/49698914bb4892678ec7e717e0c91b7d to your computer and use it in GitHub Desktop.
Jaibroken test
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; | |
} | |
NSError *error; | |
NSString *stringToBeWritten = @"This is a test."; | |
[stringToBeWritten writeToFile:@"/private/jailbreak.txt" atomically:YES | |
encoding:NSUTF8StringEncoding error:&error]; | |
if(error==nil){ | |
// Device is jailbroken | |
return YES; | |
} else { | |
[[NSFileManager defaultManager] removeItemAtPath:@"/private/jailbreak.txt" error:nil]; | |
} | |
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]){ | |
// Device is jailbroken | |
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