[iOS] 탈옥체크하기 (iOS Jailbreak Check)
탈옥한 폰에서 앱을 사용하는 것은 문제가 없을 수 있으나, B2B 업무에서는 정보의 보안에 대해 매우 중요하게 생각하고 있다. ipa를 빼거나 분석하여 내부에 있는 정보를 가져가는 행위를 막고자 극단적인 탈옥시 앱 팅기기를 구현해 놓았다.
탈옥구분하는 코드 공유차원으로 남겨놓는다.
Swift
/// 탈옥여부 체크하기. @objc func isJailbroken() -> Bool { #if targetEnvironment(simulator) print("It's an iOS Simulator") return false #else print("It's a device") // 악의적으로 Cydia파일 경로를 수정하는 경우 SSH데몬, 쉘 인터프리터 위치 확인 및 탈옥 디바이스에서 애플리 케이션을 실행 하기 위해 필요한 Mobilesubstrate 파일 위치 체크 if FileManager.default.fileExists(atPath:"/Applications/Cydia.app") || 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") { return true } else { return false } #endif }
Objective C (Objc)
- (BOOL)isJailbroken{ #if !(TARGET_IPHONE_SIMULATOR) //탈옥한 경우 대부분의 탈옥 소프트 웨어는 Cydia를 설치 하기 때문에 Cydia 파일 경로 확인 if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"]){ return YES; } //악의적으로 Cydia파일 경로를 수정하는 경우 SSH데몬, 쉘 인터프리터 위치 확인 및 탈옥 디바이스에서 애플리 케이션을 실행 하기 위해 필요한 Mobilesubstrate 파일 위치 체크 else if([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"]){ return YES; }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"]){ return YES; }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"]){ return YES; }else if([[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"]){ return YES; } return NO; #endif //All checks have failed. Most probably, the device is not jailbroken return NO; }
댓글
댓글 쓰기