iOS 判断系统是否越狱的代码

+ (BOOL) hasCydia{

    return [[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"];

}

+ (BOOL) hasAPT

{

   return [[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"];

+ (BOOL) successCallSystem

{

    return (system("ls") == 0) ? YES : NO;

}

+ (bool) testLibEnv

{

    char *env = getenv("DYLD_INSERT_LIBRARIES");

    NSLog(@"%s", env);

    return env != NULL;

}

+ (BOOL) isJailbreak

{

    BOOL b0 = [self hasCydia],

    b1 = [self hasAPT],

    b2 = [self successCallSystem],

    b3 = [self testLibEnv];

    return b0||b1||b2||b3;

}

你可能感兴趣的:(ios)