Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. ///Discussion:
  2. ///In theory, if app is able to have visibility of a file outside the app's environment then it is jailbroken.
  3. ///For this test, we will be checking for common files found from various ways of jailbreaking an iOS device.
  4.  
  5. ///As a final test: try writing outside of the app's sandbox.
  6. func isJailbroken() -> Bool{
  7. #if targetEnvironment(simulator)
  8. return false
  9. #else
  10. let fm = FileManager.default
  11. var isJailbroken: Bool = false
  12. 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")
  13.  
  14. let stringToWrite = "Jailbreak Test”"
  15. do {
  16. try stringToWrite.write(toFile:"/private/JailbreakTest.txt", atomically:true, encoding: String.Encoding.utf8)
  17. return true
  18. } catch {
  19. isJailbroken = isJailbroken || false
  20. }
  21.  
  22. return isJailbroken
  23. #endif
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement