方法一,检测文静与路径的方法
代码如下:
-(BOOL)isJailBroken{
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;
}
return NO;
方法二,检测链接
可以检测URL SCHEME或者SSH链接,代码如下:
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://"]]){
return YES;
}
方法三,检测沙箱环境
主要是检测读权限、检测写权限、检测可执行权限、已加载dylib、关键函数宿主
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/User/Applications/"]){
NSArray *applist = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:@"/User/Applications/"
error:nil];
if (applist != nil || [applist count] > 0 ) {
return YES;
}
}// 可以是NSFileManager
[@"test" writeToFile:@"/private/test.txt" atomically:YES encoding:NSUTF8StringEncoding error:nil];
if (error == nil) {
return YES;
}
int forkValue = system(-1); // 可以是fork()
if (forkValue > 0) {
return YES;
}
网友评论