#pragma mark
-(void)checkDeviceBroken
{
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
[userDefaultsetBool:NO forKey:@"DeviceBrokenCheckOut"];//强制每次都检查
if(![userDefaultboolForKey:@"DeviceBrokenCheckOut"]) {
if([selfisJailBreak]||printEnv()) {
//您的设备已越狱,存在安全隐患!
}
[userDefaultsetBool:YESforKey:@"DeviceBrokenCheckOut"];
}
}
#pragma mark
char* printEnv(void)
{
char *env = getenv("DYLD_INSERT_LIBRARIES");
returnenv;
}
- (BOOL)isJailBreak{
intresult =fork();
/*子进程要退出*/
if(!result)exit(0);
/*创建子进程,创建成功说明操作系统已经越狱了*/
returnresult>=0?YES:NO;
}