Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Discussion:
- ///In theory, if app is able to have visibility of a file outside the app's environment then it is jailbroken.
- ///For this test, we will be checking for common files found from various ways of jailbreaking an iOS device.
- ///As a final test: try writing outside of the app's sandbox.
- func isJailbroken() -> Bool{
- #if targetEnvironment(simulator)
- return false
- #else
- let fm = FileManager.default
- var isJailbroken: Bool = false
- isJailbroken = fm.fileExists(atPath: "/private/var/lib/apt") || fm.fileExists(atPath: "/etc/apt") || fm.fileExists(atPath: "/usr/sbin/sshd") || fm.fileExists(atPath: "/bin/bash") || fm.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") || fm.fileExists(atPath: "/Applications/Cydia.app")
- let stringToWrite = "Jailbreak Test”"
- do {
- try stringToWrite.write(toFile:"/private/JailbreakTest.txt", atomically:true, encoding: String.Encoding.utf8)
- return true
- } catch {
- isJailbroken = isJailbroken || false
- }
- return isJailbroken
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement