iOS MDM:我们能知道设备是 root 还是越狱吗?

iOS MDM: Can we get to know whether device is rooted or jailbroken?

我正在为 iOS 进行 MDM 实施。我想知道是否有任何命令可以让我们知道 iOS 设备是否已 root 或越狱?

我看过 MDM 协议参考,但我没有在 DeviceInformation 命令中找到任何字段来了解这一点。

服务器如何从设备知道这个状态?

您可以使用 NSFileManager 查找 Cydia(或类似应用)。并且您应该检查您是否有权访问 phone 上的 bash。你可以尝试这样的事情:

- (BOOL) isJailbroken
{    
    //If the app is running on the simulator
#if TARGET_IPHONE_SIMULATOR
    return NO;

    //If its running on an actual device
#else
    BOOL isJailbroken = NO;

    //This line checks for the existence of Cydia
    BOOL cydiaInstalled = [[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"];

    FILE *f = fopen("/bin/bash", "r");

    if (!(errno == ENOENT) || cydiaInstalled) {

        //Device is jailbroken
        isJailbroken = YES;
    }
    fclose(f);
    return isJailbroken;
#endif
}

此代码未经过真正测试。如果有效,请告诉我。

Apple MDM 协议无法检查设备是否越狱。 MDM 供应商通常会为此提出自己的解决方案。