ios 检测是否越狱代码

ios 检测是否越狱代码

 

尚未调研一定靠谱的方案,有个方案如下:


@interface UIDevice (Helper)
- (BOOL)isJailbroken;
@end

@implementation UIDevice (Helper)
- (BOOL)isJailbroken {
BOOL jailbroken = NO;
NSString *cydiaPath = @"/Applications/Cydia.app";
NSString *aptPath = @"/private/var/lib/apt/";
if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {
jailbroken = YES;
}
if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {
jailbroken = YES;
}
return jailbroken;
}

 

**********************************************************

1. apt
- (BOOL) hasAPT
{
return [[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"];
}

2. system
- (BOOL) successCallSystem
{
return (system("ls") == 0) ? YES : NO;

}

 

3

staticconstchar* jailbreak_apps[] ={    "/Applications/Cydia.app",    "/Applications/limera1n.app",    "/Applications/greenpois0n.app",    "/Applications/blackra1n.app",    "/Applications/blacksn0w.app",    "/Applications/redsn0w.app",    NULL,}; - (BOOL) isJailBroken{    // Now check for known jailbreak apps. If we encounter one, the device is jailbroken.    for(inti = 0; jailbreak_apps[i] != NULL; ++i)    {        if([[NSFileManagerdefaultManager] fileExistsAtPath:[NSStringstringWithUTF8String:jailbreak_apps[i]]])        {            //NSLog(@"isjailbroken: %s", jailbreak_apps[i]);            returnYES;        }    }         // TODO: Add more checks? This is an arms-race we're bound to lose.         returnNO;}
 
posted on 2012-11-21 15:40  smartch  阅读(256)  评论(0编辑  收藏  举报