iOS 判断是否越狱设备

越狱设备打印  

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/Applications/Cydia.app"]

YES    

 (lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/private/var/lib/apt"]

YES     

 (lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/usr/lib/system/libsystem_kernel.dylib"]

NO   

  (lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"Library/MobileSubstrate/MobileSubstrate.dylib"]

YES

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/etc/apt"]

YES

非越狱设备打印

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/Applications/Cydia.app"]

NO

(lldb)  po [[NSFileManager defaultManager ] fileExistsAtPath:@"/private/var/lib/apt"]

NO

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/usr/lib/system/libsystem_kernel.dylib"]

YES

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"Library/MobileSubstrate/MobileSubstrate.dylib"]

NO

(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/etc/apt"]

NO

根据上面的打印结果可以看出要想判断是否越狱 检查如下路径文件是否存在

1、"/Applications/Cydia.app" 存在 越狱

2、"/private/var/lib/apt" 存在 越狱

3、"/usr/lib/system/libsystem_kernel.dylib"  不存在 越狱

4、"Library/MobileSubstrate/MobileSubstrate.dylib" 存在 越狱

5、"/etc/apt" 存在 越狱


- (BOOL)isJailBreak{

  __block BOOL jailBreak = NO;

    NSArray *array = @[@"/Applications/Cydia.app",@"/private/var/lib/apt",@"/usr/lib/system/libsystem_kernel.dylib",@"Library/MobileSubstrate/MobileSubstrate.dylib",@"/etc/apt"];

    [array enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {

        BOOL fileExist =  [[NSFileManager defaultManager] fileExistsAtPath:obj];

        if ([obj isEqualToString:@"/usr/lib/system/libsystem_kernel.dylib"]) {

            jailBreak |= !fileExist;

        }else{

            jailBreak |= fileExist;

        }

    }];

   return jailBreak;

}

你可能感兴趣的:(iOS 判断是否越狱设备)