Created
March 2, 2020 04:48
-
-
Save hongseok/89e0a5dc00a3d8aeef034d90ec21139d to your computer and use it in GitHub Desktop.
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
https://re-engines.com/2018/12/25/swiftios%E3%81%AE%E8%84%B1%E7%8D%84%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%82%92%E8%A1%8C%E3%81%86%E3%80%82/ | |
var isJailBroken :Bool{ | |
if TARGET_OS_SIMULATOR != 1{ | |
if checkCydia||checkPass||checkWritable{ | |
return true | |
} | |
} | |
return false | |
} | |
//Cydiaのチェック | |
var checkCydia: Bool{ | |
//Cydiaのチェックを行う | |
if FileManager.default.fileExists(atPath: "/Applications/Cydia.app")||UIApplication.shared.canOpenURL(URL(string: "cydia://")!){ | |
//Cydiaのパスが存在するため脱獄と判断 | |
return true | |
} | |
return false | |
} | |
//Passのチェック | |
var checkPass: Bool{ | |
// ファイルが存在するか確認を行うほiOS端末では存在しないディレクトリのチェック | |
if FileManager.default.fileExists(atPath: "/Library/MobileSubstrate/MobileSubstrate.dylib") | |
|| FileManager.default.fileExists(atPath: "/bin/bash") | |
|| FileManager.default.fileExists(atPath: "/usr/sbin/sshd") | |
|| FileManager.default.fileExists(atPath: "/etc/apt") | |
|| FileManager.default.fileExists(atPath: "/private/var/lib/apt/"){ | |
//パスが存在したため脱獄と判断 | |
return true | |
} | |
return false | |
} | |
//ファイルの書き込み権限のテスト | |
var checkWritable: Bool{ | |
// 本来であれば書き込みの権限がない箇所に書き込みができるかチェック | |
let stringToWrite = "Jailbreak" | |
do{ | |
try stringToWrite.write(toFile:"/private/JailbreakTest.txt", atomically:true, encoding:String.Encoding.utf8) | |
//書き込めたため脱獄と判断 | |
return true | |
}catch{ | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment