越狱屏蔽检测,或者把正常文件提取出来安装在越狱后的手机上。

解决方案 »

  1.   

    +(BOOL) isJailbroken
    {
    #if TARGET_IPHONE_SIMULATOR
        return NO;
    #else
        NSFileManager* fileManager = [NSFileManager defaultManager];
        
        // check for some files that will exist on most jailbroken devices
        if ([fileManager fileExistsAtPath:@"/Applications/Cydia.app"] ||
            [fileManager fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] ||
            [fileManager fileExistsAtPath:@"/bin/bash"] ||
            [fileManager fileExistsAtPath:@"/usr/sbin/sshd"] ||
            [fileManager fileExistsAtPath:@"/etc/apt"]) {
            return YES;
        }
        
        // check if we can write to private directories
        BOOL ok = [@"test" writeToFile:@"/private/jailbreak.txt.fiekaoi39fkd39akld" atomically:YES encoding:NSUTF8StringEncoding error:nil];
        if (ok) {
            [fileManager removeItemAtPath:@"/private/jailbreak.txt.fiekaoi39fkd39akld" error:nil];
            return YES;
        }
        
        // check if the device can open cydia urls
        if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]]){
            return YES;
        }
        
        return NO;
    #endif
    }