Last active
June 22, 2022 17:44
-
-
Save rtking1993/391ff04d6a1aafbfde104d0fd8fb7c67 to your computer and use it in GitHub Desktop.
Jailbreak detector
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
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