Skip to content

Instantly share code, notes, and snippets.

@xkef
Last active May 8, 2020 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkef/7039b37c529c759ff615af439e2d5c69 to your computer and use it in GitHub Desktop.
Save xkef/7039b37c529c759ff615af439e2d5c69 to your computer and use it in GitHub Desktop.
ios jailbreak: detection and bypass

From /TheSwiftyCoder/JailBreak-Detection:

static func isJailbroken() -> Bool {
		
		guard let cydiaUrlScheme = NSURL(string: "cydia://package/com.example.package") else { return false }
		if UIApplication.shared.canOpenURL(cydiaUrlScheme as URL) {
			return true
		}
		
		#if arch(i386) || arch(x86_64)
			// This is a Simulator not an idevice
			return false
		#endif
		
		let fileManager = FileManager.default
		if fileManager.fileExists(atPath: "/Applications/Cydia.app") ||
			fileManager.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
			fileManager.fileExists(atPath: "/bin/bash") ||
			fileManager.fileExists(atPath: "/usr/sbin/sshd") ||
			fileManager.fileExists(atPath: "/etc/apt") ||
			fileManager.fileExists(atPath: "/usr/bin/ssh") ||
			fileManager.fileExists(atPath: "/private/var/lib/apt") {
			return true
		}
		
		if canOpen(path: "/Applications/Cydia.app") ||
			canOpen(path: "/Library/MobileSubstrate/MobileSubstrate.dylib") ||
			canOpen(path: "/bin/bash") ||
			canOpen(path: "/usr/sbin/sshd") ||
			canOpen(path: "/etc/apt") ||
			canOpen(path: "/usr/bin/ssh") {
			return true
		}
		
		let path = "/private/" + NSUUID().uuidString
		do {
			try "anyString".write(toFile: path, atomically: true, encoding: String.Encoding.utf8)
			try fileManager.removeItem(atPath: path)
			return true
		} catch {
			return false
		}
	}
	
	static func canOpen(path: String) -> Bool {
		let file = fopen(path, "r")
		guard file != nil else { return false }
		fclose(file)
		return true
	}

Sometimes it's pretty easy.

Jailbreak Detection

!Jailbreak Detection: change value to false...

(UBS E-Banking)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment