苹果拒绝越狱检测的应用程序

我们正在处理的应用程序被拒绝,因为在审查过程中的设备被检测为越狱^^

为了检测越狱设备,进行了几个testing:

NSString* bundlePath = [[NSBundle mainBundle] bundlePath]; // scan for itunes metadata BOOL isDirectory = NO; NSString* directoryPath = [bundlePath stringByAppendingPathComponent:@"SC_Info/"]; BOOL directoryIsAvailable = [[NSFileManager defaultManager] fileExistsAtPath:directoryPath isDirectory:&isDirectory]; BOOL contentSeemsValid = ([[[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:NULL] count] == 2); if (directoryIsAvailable && contentSeemsValid) { return YES; } contentSeemsValid = [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/iTunesMetadata.​plist", bundlePath]]; if (contentSeemsValid) { return YES; } // scan for cydia app NSURL* testURL = [NSURL URLWithString:@"cydia://"]; if ([[UIApplication sharedApplication] canOpenURL:testURL]) { return YES; } // scan for paths available NSArray* paths = @[@"/Applications/Cydia.app", @"/Applications/RockApp.app", @"/Applications/Icy.app", @"/usr/sbin/sshd", @"/usr/bin/sshd", @"/private/var/lib/apt", @"/private/var/lib/cydia", @"/private/var/stash", @"/usr/libexec/sftp-server"]; for (NSString* string in paths) { if ([[NSFileManager defaultManager] fileExistsAtPath:string]) { return YES; } } // scan for forking int forkValue = fork(); if (forkValue >= 0) { return YES; } // try to write in private space NSString* testString = @"test"; NSError* error = nil; [testString writeToFile:@"/private/test.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error]; if (error == nil) { return YES; } // seems not jailbroken return NO; 

这些testing中的一个(或多个)在苹果公司用于审查的设备上返回YES,但不是我们的DevDevices。 哪一个可能? 有人知道更多关于苹果公司用于审查的设备的细节吗? 任何提示或其他猜测? (应用程序的上下文是医院的医疗保健,所以我们需要确保患者数据是保存的)

最好的祝福,
Zeek

https://www.theiphonewiki.com/wiki/Bypassing_Jailbreak_Detection

虽然应用程序可以通过无数种方式实现对越狱设备的检查,但通常归结为以下几点:

目录的存在 – 检查你的文件系统中的/Applications/Cydia.app//private/var/stash等path。 大部分情况下,在-(BOOL)fileExistsAtPath:(NSString*)path使用-(BOOL)fileExistsAtPath:(NSString*)path方法NSFileManager ,但更多的偷偷摸摸的应用程序喜欢使用fopen()stat()access()等更低级的C函数。

目录权限 – 使用NSFileManager方法以及像statfs()这样的C函数检查特定文件和目录的Unix文件权限。 在越狱的设备上有更多的目录可以访问,而不是在监狱里。

进程分叉sandboxd不会拒绝App Store应用程序使用fork()popen()或任何其他C函数在非越狱设备上创buildsubprocess的能力。 sandboxd明确拒绝jail设备上的进程分叉。 如果你在fork()上检查返回的pid,你的应用程序可以判断它是否成功分叉,在这一点上它可以确定设备的越狱状态。

SSH环回连接* – 由于大部分安装了OpenSSH的越狱设备,一些应用程序将尝试连接到端口22上的127.0.0.1。如果连接成功,则意味着OpenSSH已安装并在设备上运行,因此它是越狱。

system() – 在jail设备上用NULL参数调用system()函数将返回0; 在越狱设备上做同样的事情将返回1.这是因为该function将检查/bin/sh是否存在,而这仅仅是在越狱设备上的情况。

dyld函数 – 到目前为止最难以解决的问题。 调用像_dyld_image_count()_dyld_get_image_name()函数来查看当前加载了哪些dylib。 很难修补,因为修补程序本身就是dylibs一部分。

*只有极less数的应用程序实现这一点(因为它不如其他的有效)

这些方法似乎是不太可能被苹果拒绝,使用起来非常简单。

上面的这段文字是为了简洁而编辑的