Skip to content

Instantly share code, notes, and snippets.

@rtking1993
Last active June 22, 2022 17:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rtking1993/391ff04d6a1aafbfde104d0fd8fb7c67 to your computer and use it in GitHub Desktop.
Save rtking1993/391ff04d6a1aafbfde104d0fd8fb7c67 to your computer and use it in GitHub Desktop.
Jailbreak detector
extension UIDevice {
private class JailbreakDetector {
static var current: JailbreakDetector = JailbreakDetector()
lazy var containsSuspiciousFiles: Bool = {
return (["/Applications/Cydia.app",
"/Library/MobileSubstrate/MobileSubstrate.dylib",
"/bin/bash",
"/usr/sbin/sshd",
"/etc/apt",
"/private/var/lib/apt/"].first(where: {
FileManager.default.fileExists(atPath: $0)
}) != nil)
}()
}
/// Whether user is using jailbroken device
var isJailbroken: Bool {
guard self == UIDevice.current else {
return false
}
// Check that we are not using the simulator
#if arch(i386) || arch(x86_64)
return false
#else
return JailbreakDetector.current.containsSuspiciousFiles
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment