如何检查iPhone是否被迅速越狱?

时间:2018-04-06 07:39:16

标签: ios swift

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

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

1 个答案:

答案 0 :(得分:-2)

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

}