在安装了xCon包的IOS中检测JailBroken手机

时间:2017-03-23 05:57:46

标签: ios objective-c iphone xcode jailbreak

我发现多篇文章解释了检测JailBroken手机方法的一般方法。

其中一个密切参考是:https://github.com/masbog/isJB

但是在xCon安装的设备上测试时没有检测到Jailbroken。

如果我们有一个财务应用程序需要被阻止,如果设备是JB,即使安装了xCon,我们也可以检测到。

真正感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

  • Swift越狱检查:

    static func isJailbroken() -> Bool {
    
    guard let cydiaUrlScheme = NSURL(string: "cydia://package/com.example.package") else { return false }
    if UIApplication.shared.canOpenURL(cydiaUrlScheme as URL) {
        return false
    }
    
    #if arch(i386) || arch(x86_64)
        // This is a Simulator not an idevice
        return false
    #endif
    let fileManager = FileManager.default
    if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
        fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
        fileManager.fileExists(atPath: "/bin/bash") ||
        fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
        fileManager.fileExists(atPath: "/etc/apt") ||
        fileManager.fileExists(atPath: "/usr/bin/ssh") ||
        fileManager.fileExists(atPath: "/private/var/lib/apt") {
        return true
    }
    if canOpen(path: "/Applications/Cydia.app") ||
        canOpen(path: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
        canOpen(path: "/bin/bash") ||
        canOpen(path: "/usr/sbin/sshd") ||
        canOpen(path: "/etc/apt") ||
        canOpen(path: "/usr/bin/ssh") {
        return true
    }
    let path = "/private/" + NSUUID().uuidString
    do {
        try "anyString".write(toFile: path, atomically: true, encoding: String.Encoding.utf8)
        try fileManager.removeItem(atPath: path)
        return true
    } catch {
        return false
    }
    }
    
    static func canOpen(path: String) -> Bool {
        let file = fopen(path, "r")
        guard file != nil else { return false }
        fclose(file)
        return true
    }