Skip to content

Instantly share code, notes, and snippets.

@PGMY
Last active July 28, 2017 03:39
Show Gist options
  • Save PGMY/c612ae3e746dfe1f9816 to your computer and use it in GitHub Desktop.
Save PGMY/c612ae3e746dfe1f9816 to your computer and use it in GitHub Desktop.
iOS脱獄チェックメモ ref: http://qiita.com/PGMY/items/3ceae5cbbf93e013deb4
+(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;
}
FILE *f = fopen("/bin/bash", "r");
BOOL isJB = NO;
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/bin/ssh", "r");
if ( f != NULL){
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Applications/Cydia.app", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/usr/sbin/sshd", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/etc/apt", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
if(isJB) return YES;
NSFileManager * fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:@"/private/var/lib/apt/"]){
//Device is jailbroken
return YES;
}
#endif
//All checks have failed. Most probably, the device is not jailbroken
return NO;
}
+(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;
}
FILE *f = fopen("/bin/bash", "r");
BOOL isJB = NO;
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/bin/ssh", "r");
if ( f != NULL){
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Applications/Cydia.app", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/usr/sbin/sshd", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/etc/apt", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
if(isJB) return YES;
NSFileManager * fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:@"/private/var/lib/apt/"]){
//Device is jailbroken
return YES;
}
#endif
//All checks have failed. Most probably, the device is not jailbroken
return NO;
}
+ (BOOL)isJailbroken
{
#if !(TARGET_IPHONE_SIMULATOR)
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]) {
// return YES;
NSLog(@"1");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]) {
// return YES;
NSLog(@"2");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"]) {
// return YES;
NSLog(@"3");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"]) {
// return YES;
NSLog(@"4");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"]) {
// return YES;
NSLog(@"5");
}
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;
NSLog(@"6");
} 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;
NSLog(@"7");
}
FILE *f = fopen("/bin/bash", "r");
BOOL isJB = NO;
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"8");
}
fclose(f);
f = fopen("/bin/ssh", "r");
if ( f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"9");
}
fclose(f);
f = fopen("/Applications/Cydia.app", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"10");
}
fclose(f);
f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"11");
}
fclose(f);
f = fopen("/usr/sbin/sshd", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"12");
}
fclose(f);
f = fopen("/etc/apt", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"13");
}
fclose(f);
if (isJB) {
// return YES;
NSLog(@"14");
}
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:@"/private/var/lib/apt/"]) {
// Device is jailbroken
// return YES;
NSLog(@"15");
}
#endif /* if !(TARGET_IPHONE_SIMULATOR) */
// All checks have failed. Most probably, the device is not jailbroken
return NO;
}
+ (BOOL)isJailbroken
{
#if !(TARGET_IPHONE_SIMULATOR)
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]) {
// return YES;
NSLog(@"1");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]) {
// return YES;
NSLog(@"2");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"]) {
// return YES;
NSLog(@"3");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"]) {
// return YES;
NSLog(@"4");
} //else
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"]) {
// return YES;
NSLog(@"5");
}
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;
NSLog(@"6");
} 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;
NSLog(@"7");
}
FILE *f = fopen("/bin/bash", "r");
BOOL isJB = NO;
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"8");
}
fclose(f);
f = fopen("/bin/ssh", "r");
if ( f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"9");
}
fclose(f);
f = fopen("/Applications/Cydia.app", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"10");
}
fclose(f);
f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"11");
}
fclose(f);
f = fopen("/usr/sbin/sshd", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"12");
}
fclose(f);
f = fopen("/etc/apt", "r");
if (f != NULL) {
// Device is jailbroken
isJB = YES;
NSLog(@"13");
}
fclose(f);
if (isJB) {
// return YES;
NSLog(@"14");
}
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:@"/private/var/lib/apt/"]) {
// Device is jailbroken
// return YES;
NSLog(@"15");
}
#endif /* if !(TARGET_IPHONE_SIMULATOR) */
// All checks have failed. Most probably, the device is not jailbroken
return NO;
}
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]])
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]])
1
3
5
7
8
10
13
14
15
2
5
10
11
12
13
14
+(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;
}
FILE *f = fopen("/bin/bash", "r");
BOOL isJB = NO;
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/bin/ssh", "r");
if ( f != NULL){
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Applications/Cydia.app", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/usr/sbin/sshd", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
f = fopen("/etc/apt", "r");
if (f != NULL)
{
//Device is jailbroken
isJB = YES;
}
fclose(f);
if(isJB) return YES;
NSFileManager * fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:@"/private/var/lib/apt/"]){
//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