** 判断iPhone是否越狱 **
-
** 注意以下代码不要单独写在一个方法里将是否越狱的状态返回(越狱之后可以修改方法的返回值) **
//是否越狱
BOOL jailBroken = false;
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia:"]]) {
jailBroken = YES;
}
#define ARRAY_SIZE(a) sizeof(a)/sizeof(a[0])
const char* jailbreak_tool_pathes[] = {
"/Applications/Cydia.app",
"/Library/MobileSubstrate/MobileSubstrate.dylib",
"/bin/bash",
"/usr/sbin/sshd",
"/etc/apt"
};
for (int i=0; i<ARRAY_SIZE(jailbreak_tool_pathes); i++) {
if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithUTF8String:jailbreak_tool_pathes[i]]]) {
NSLog(@"The device is jail broken!");
jailBroken = YES;
}
}
#define USER_APP_PATH @"/User/Applications/"
if ([[NSFileManager defaultManager] fileExistsAtPath:USER_APP_PATH]) {
NSLog(@"The device is jail broken!");
NSArray *applist = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:USER_APP_PATH error:nil];
NSLog(@"applist = %@", applist);
jailBroken = YES;
}
NSLog(@"------%d-",jailBroken);
以上进行了3次越狱检测
方法名不要太直接 太明显