Rah*_*yas 50
您可以通过代码检测应用程序是否在监狱设备上运行.通过这种方式,您可以弹出警报并关闭应用程序.你可以做任何你想做的事.这是一个教程:
http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html
这是一个Stack Overflow帖子:
此外,如果您想要一个完整的解决方案,您可以在tapjoy sdk代码中看到.他们正在检测已越狱的iPhone.这是tapjoy网址https://www.tapjoy.com/
检查这些路径
+ (BOOL)isJailBroken {
#ifdef TARGET_IPHONE_SIMULATOR
return NO;
#endif
NSArray *paths = @[@"/bin/bash",
@"/usr/sbin/sshd",
@"/etc/apt",
@"/private/var/lib/apt/",
@"/Applications/Cydia.app",
];
for (NSString *path in paths) {
if ([self fileExistsAtPath:path]) {
return YES;
}
}
return NO;
}
+ (BOOL)fileExistsAtPath:(NSString *)path {
FILE *pFile;
pFile = fopen([path cStringUsingEncoding:[NSString defaultCStringEncoding]], "r");
if (pFile == NULL) {
return NO;
}
else
fclose(pFile);
return YES;
}
Run Code Online (Sandbox Code Playgroud)
尝试找到cydia或越狱设备创建的文件.或者尝试在应用程序的黑盒子外写一个文件.如果你成功了,那么该设备会遭到入侵/越狱:)
- (BOOL)jailbroken
{
NSFileManager * fileManager = [NSFileManager defaultManager];
return [fileManager fileExistsAtPath:@"/private/var/lib/apt/"];
}
Run Code Online (Sandbox Code Playgroud)
/**
Detect that the app is running on a jailbroken device or not
- returns: bool value for jailbroken device or not
*/
public class func isDeviceJailbroken() -> Bool {
#if arch(i386) || arch(x86_64)
return false
#else
let fileManager = FileManager.default
if (fileManager.fileExists(atPath: "/bin/bash") ||
fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
fileManager.fileExists(atPath: "/etc/apt") ||
fileManager.fileExists(atPath: "/private/var/lib/apt/") ||
fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib")) {
return true
} else {
return false
}
#endif
}
Run Code Online (Sandbox Code Playgroud)