Apple拒绝越狱检测应用程序

Zee*_*eek 7 objective-c jailbreak app-store ios

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

为了检测越狱设备,进行了几次测试:

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;
Run Code Online (Sandbox Code Playgroud)

这些测试中的一个(或多个)在Apple用于Review的设备上返回YES,但没有一个我们的DevDevices.可能是哪一个?有没有人知道更多有关Apple用于评论的设备的详细信息?任何提示或其他猜测?(应用程序的上下文是医院的医疗保健,因此我们需要确保患者数据被保存)

最诚挚的问候,
Zeek

Mor*_*ode 5

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

虽然应用程序可以通过无数种方式对越狱设备进行检查,但它们通常归结为以下内容:

目录的存在 - 检查文件系统中的路径,例如/Applications/Cydia.app//private/var/stash其他一些路径.多数情况下,这些所使用的检查-(BOOL)fileExistsAtPath:(NSString*)path中的方法NSFileManager,但更偷偷摸摸应用喜欢用较低级-C的功能,如fopen(),stat(),或access().

目录权限 - 使用NSFileManager方法和C函数检查特定文件和目录的Unix文件权限statfs().更多目录在越狱设备上具有写访问权限,而不是仍然在监狱中.

流程分叉 - sandboxd不否认App Store的应用程序使用的能力fork(),popen()或任何其他C函数来创建非越狱的设备子进程.sandboxd明确拒绝在监狱中的设备上进行分叉.如果您检查返回的pid fork(),您的应用程序可以判断它是否已成功分叉,此时它可以确定设备的越狱状态.

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

system() - system()在jail中的设备上调用带有NULL参数的函数将返回0; 在越狱设备上做同样的操作将返回1.这是因为该函数将检查是否/bin/sh存在,这只是越狱设备的情况.[1]

dyld功能 - 到目前为止最困难的.调用函数,_dyld_image_count()以及_dyld_get_image_name()查看当前加载的dylib.很难修补,因为补丁本身就是其中的一部分dylibs.

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

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

为简洁起见,上述段落已被编辑