欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS 判断是否越狱设备

程序员文章站 2022-10-25 12:05:12
越狱设备打印(lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/Applications/Cydia.app"]YES (lldb) po [[NSFileManager defaultManager ] fileExistsAtPath:@"/private/var/lib/apt"]YES (lldb) po [[NSFileManager defaultManager ] fileEx......

越狱设备打印  

(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;

}

本文地址:https://blog.csdn.net/Android_liangyi/article/details/107102090