【问题标题】:how to check if an iPhone is jailbroked or not in swift? [duplicate]如何快速检查iPhone是否越狱? [复制]
【发布时间】:2018-09-16 04:27:00
【问题描述】:

我想防止用户伪造 GPS 坐标,如果 iPhone 越狱,可以运行一个应用程序来伪造 GPS。所以为了防止这个问题我想检查用户是否越狱,如果用户使用越狱的iPhone,我会强制关闭应用程序。

如何在 Swift 中做到这一点?到目前为止我在stackoverflow中找不到它

【问题讨论】:

标签: ios swift


【解决方案1】:

Jailbreak medium article 提供了一个非常好的概要

if TARGET_IPHONE_SIMULATOR != 1

{

// Check 1 : existence of files that are common for jailbroken devices

if FileManager.default.fileExists(atPath: “/Applications/Cydia.app”)

|| FileManager.default.fileExists(atPath: “/Library/MobileSubstrate/MobileSubstrate.dylib”)

|| FileManager.default.fileExists(atPath: “/bin/bash”)

|| FileManager.default.fileExists(atPath: “/usr/sbin/sshd”)

|| FileManager.default.fileExists(atPath: “/etc/apt”)

|| FileManager.default.fileExists(atPath: “/private/var/lib/apt/”)

|| UIApplication.shared.canOpenURL(URL(string:”cydia://package/com.example.package”)!)

{

return true

}

// Check 2 : Reading and writing in system directories (sandbox violation)

let stringToWrite = “Jailbreak Test”

do

{

try stringToWrite.write(toFile:”/private/JailbreakTest.txt”, atomically:true, encoding:String.Encoding.utf8)

//Device is jailbroken

return true

}catch

{

return false

}

}else

{

return false

}

【讨论】:

    猜你喜欢
    • 2011-02-21
    • 2011-05-21
    • 2021-03-08
    • 2019-10-01
    • 2019-10-31
    • 2020-10-23
    • 2011-09-25
    • 1970-01-01
    • 2019-08-09
    相关资源
    最近更新 更多