Created
July 12, 2019 15:56
-
-
Save mmdock/530f9dfc6f169bb2938329f11cce81a2 to your computer and use it in GitHub Desktop.
iOS Simple Jailbroken Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment