IOS判断设备是否已越狱

转自:http://www.cnblogs.com/supercheng/archive/2012/12/05/2804166.html

- (BOOL)isJailbroken
{
BOOL jailbroken = NO; NSString *cydiaPath = @"/Applications/Cydia.app"; NSString *aptPath = @"/private/var/lib/apt/"; if ([[NSFileManagerdefaultManager] fileExistsAtPath:cydiaPath]) {
jailbroken = YES;
} if ([[NSFileManagerdefaultManager] fileExistsAtPath:aptPath]) {
jailbroken = YES;
} return jailbroken; }
判断软件是否被破解应该是就判断有没有加那个key吧?

Info.list

  <key>SignerIdentity</key>

  <string>Apple iPhone OS Application Signing</string>

IOS判断设备是否已越狱

转载

正文开始

Umeng统计的Mobclick.h里面已经包含了越狱检测的代码,可以直接使用

/*方法名: * isJailbroken *介绍: * 类方法,判断设备是否越狱,判断方法根据 apt和Cydia.app的path来判断 *参数说明: * 无 * * *

/#pragma mark utils api //类方法,判断当前设备是否已经越狱

+ (BOOL)isJailbroken; //类方法,判断你的App是否被破解

+ (BOOL)isPirated;

apt和Cydia的方式来进行判断的,没看见源码

然后再介绍两种方法来查看是否已经越狱,知其然知其所以然、、、

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",

"/Applications/Absinthe.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;

}

@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;  
}  
@end

上一篇:Oracle EBS OPM 创建生产批


下一篇:Android之判断设备网络连接状态,并判断连接方式