
IOSSecuritySuite v2.3.0
iOS 플랫폼 보안 및 위변조 방지 Swift 라이브러리
⭐️ 인증된 iOS 애플리케이션 보안 엔지니어가 되고 싶으신가요? ⭐️
실용적이고 완전 온라인 강좌를 확인하세요: https://courses.securing.pl/courses/iase

ISS 설명

작성자: @_r3ggi
🌏 iOS Security Suite는 순수 Swift로 작성된 고급스럽고 사용하기 쉬운 플랫폼 보안 및 변조 방지 라이브러리입니다! iOS 개발을 하고 있고 OWASP MASVS 표준의 v8장에 따라 앱을 보호하려는 경우, 이 라이브러리가 많은 시간을 절약해 줄 수 있습니다. 🚀
ISS가 탐지하는 것:
- 탈옥 🧨
- 연결된 디버거 👨🏻🚀
- 에뮬레이터에서 실행 중인지 👽
- 실행 중인 일반적인 리버스 엔지니어링 도구 🔭
설정
IOSSecuritySuite 사용을 시작하는 4가지 방법이 있습니다.
1. 소스 추가
IOSSecuritySuite/*.swift 파일을 프로젝트에 추가하세요
2. CocoaPods로 설정
pod 'IOSSecuritySuite'
3. Carthage로 설정
github "securing/IOSSecuritySuite"
4. Swift Package Manager로 설정
.package(url: "https://github.com/securing/IOSSecuritySuite.git", from: "1.5.0")
Info.plist 업데이트
프로젝트에 ISS를 추가한 후에는 메인 Info.plist도 업데이트해야 합니다. 탈옥 탐지 모듈에는 canOpenURL(_:) 메서드를 사용하는 검사가 있으며, 쿼리할 URL을 지정해야 합니다. (참고)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>undecimus</string>
<string>sileo</string>
<string>zbra</string>
<string>filza</string>
</array>
가격 정책
자세한 내용은 EULA 라이선스를 확인하세요.
요약: 회사에 직원이 있는 경우:
- 0-99명 - 무료 사용
- 100-1000명 - 연간 3,000 EUR
- 1000명 이상 - 연간 10,000 EUR
iOS Security Suite를 사용하는 모듈을 판매하려는 경우 (앱에서 직접 사용되지 않음) - 연간 10,000 EUR
주의사항
iOS Security Suite는 iOS/iPadOS에서 사용하도록 설계되었습니다. Apple Silicon이 탑재된 Mac에서는 사용해서는 안 됩니다.
사용 방법
탈옥 탐지 모듈
- 가장 간단한 방법은 기기가 탈옥되었는지 여부만 알고 싶다면 True/False를 반환합니다.
if IOSSecuritySuite.amIJailbroken() {
print("This device is jailbroken")
} else {
print("This device is not jailbroken")
}
- 상세 정보: 어떤 지표가 식별되었는지도 알고 싶다면
let jailbreakStatus = IOSSecuritySuite.amIJailbrokenWithFailMessage()
if jailbreakStatus.jailbroken {
print("This device is jailbroken")
print("Because: \(jailbreakStatus.failMessage)")
} else {
print("This device is not jailbroken")
}
failMessage는 아래 예시와 같이 쉼표로 구분된 지표를 포함하는 문자열입니다:
sileo:// URL scheme detected, Suspicious file exists: /Library/MobileSubstrate/MobileSubstrate.dylib, Fork was able to create a new process
- 상세 정보 및 필터 가능: 예를 들어 과거에 탈옥되었지만 현재는 그렇지 않은 기기를 식별하려는 경우
let jailbreakStatus = IOSSecuritySuite.amIJailbrokenWithFailedChecks()
if jailbreakStatus.jailbroken {
if (jailbreakStatus.failedChecks.contains { $0.check == .existenceOfSuspiciousFiles }) && (jailbreakStatus.failedChecks.contains { $0.check == .suspiciousFilesCanBeOpened }) {
print("This is real jailbroken device")
}
}
디버거 탐지 모듈
let amIDebugged: Bool = IOSSecuritySuite.amIDebugged()
디버거 완전 차단
IOSSecuritySuite.denyDebugger()
에뮬레이터 탐지 모듈
let runInEmulator: Bool = IOSSecuritySuite.amIRunInEmulator()
리버스 엔지니어링 도구 탐지 모듈
- 가장 간단한 방법은 기기에 리버스 엔지니어링 증거가 있는지 여부만 알고 싶다면 True/False를 반환합니다.
if IOSSecuritySuite.amIReverseEngineered() {
print("This device has evidence of reverse engineering")
} else {
print("This device hasn't evidence of reverse engineering")
}
- 상세 정보 및 필터 가능: 수행된 검사 목록도 알고 싶다면
let reverseStatus = IOSSecuritySuite.amIReverseEngineeredWithFailedChecks()
if reverseStatus.reverseEngineered {
// check for reverseStatus.failedChecks for more details
}
시스템 프록시 탐지 모듈
이제 앱이 VPN에 연결되어 있는지도 탐지할 수 있습니다.
let amIProxied: Bool = IOSSecuritySuite.amIProxied(considerVPNConnectionAsProxy: true)
잠금 모드 탐지 모듈
let amIInLockdownMode: Bool = IOSSecuritySuite.amIInLockdownMode()
실험적 기능
런타임 후크 탐지 모듈
let amIRuntimeHooked: Bool = amIRuntimeHook(dyldWhiteList: dylds, detectionClass: SomeClass.self, selector: #selector(SomeClass.someFunction), isClassMethod: false)
심볼 후크 차단 모듈
// If we want to deny symbol hook of Swift function, we have to pass mangled name of that function
denySymbolHook("$s10Foundation5NSLogyySS_s7CVarArg_pdtF") // denying hooking for the NSLog function
NSLog("Hello Symbol Hook")
denySymbolHook("abort")
abort()
MSHook 탐지 모듈
// Function declaration
func someFunction(takes: Int) -> Bool {
return false
}
// Defining FunctionType : @convention(thin) indicates a “thin” function reference, which uses the Swift calling convention with no special “self” or “context” parameters.
typealias FunctionType = @convention(thin) (Int) -> (Bool)
// Getting pointer address of function we want to verify
func getSwiftFunctionAddr(_ function: @escaping FunctionType) -> UnsafeMutableRawPointer {
return unsafeBitCast(function, to: UnsafeMutableRawPointer.self)
}
let funcAddr = getSwiftFunctionAddr(someFunction)
let amIMSHooked = IOSSecuritySuite.amIMSHooked(funcAddr)
MSHook 차단 모듈
// Function declaration
func denyDebugger(value: Int) {
}
// Defining FunctionType : @convention(thin) indicates a “thin” function reference, which uses the Swift calling convention with no special “self” or “context” parameters.
typealias FunctionType = @convention(thin) (Int)->()
// Getting original function address
let funcDenyDebugger: FunctionType = denyDebugger
let funcAddr = unsafeBitCast(funcDenyDebugger, to: UnsafeMutableRawPointer.self)
if let originalDenyDebugger = denyMSHook(funcAddr) {
// Call the original function with 1337 as Int argument
unsafeBitCast(originalDenyDebugger, to: FunctionType.self)(1337)
} else {
denyDebugger()
}
파일 무결성 검증 모듈
// Determine if application has been tampered with
if IOSSecuritySuite.amITampered([.bundleID("biz.securing.FrameworkClientApp"),
.mobileProvision("2976c70b56e9ae1e2c8e8b231bf6b0cff12bbbd0a593f21846d9a004dd181be3"),
.machO("IOSSecuritySuite", "6d8d460b9a4ee6c0f378e30f137cebaf2ce12bf31a2eef3729c36889158aa7fc")]).result {
print("I have been Tampered.")
}
else {
print("I have not been Tampered.")
}
// Manually verify SHA256 hash value of a loaded dylib
if let hashValue = IOSSecuritySuite.getMachOFileHashValue(.custom("IOSSecuritySuite")), hashValue == "6d8d460b9a4ee6c0f378e30f137cebaf2ce12bf31a2eef3729c36889158aa7fc" {
print("I have not been Tampered.")
}
else {
print("I have been Tampered.")
}
// Check SHA256 hash value of the main executable
// Tip: Your application may retrieve this value from the server
if let hashValue = IOSSecuritySuite.getMachOFileHashValue(.default), hashValue == "your-application-executable-hash-value" {
print("I have not been Tampered.")
}
else {
print("I have been Tampered.")
}
중단점 탐지 모듈
func denyDebugger() {
// Set breakpoint here
}
typealias FunctionType = @convention(thin) ()->()
let func_denyDebugger: FunctionType = denyDebugger // `: FunctionType` is a must
let func_addr = unsafeBitCast(func_denyDebugger, to: UnsafeMutableRawPointer.self)
let hasBreakpoint = IOSSecuritySuite.hasBreakpointAt(func_addr, functionSize: nil)
if hasBreakpoint {
print("Breakpoint found in the specified function")
} else {
print("Breakpoint not found in the specified function")
}
감시점 탐지 모듈
// Set a breakpoint at the testWatchpoint function
func testWatchpoint() -> Bool{
// lldb: watchpoint set expression ptr
var ptr = malloc(9)
// lldb: watchpoint set variable count
var count = 3
return IOSSecuritySuite.hasWatchpoint()
}
보안 고려사항
이 라이브러리 및 기타 플랫폼 보안 검사기를 사용하기 전에 다음을 이해해야 합니다:
- 이 도구를 프로젝트에 포함시키는 것만으로는 앱 보안을 향상시키기에 충분하지 않습니다! 일반 모바일 보안 백서는 여기에서 읽을 수 있습니다.
- 기기가 탈옥되었는지 탐지는 기기에서 로컬로 수행됩니다. 즉, 모든 탈옥 탐지기는 우회될 수 있습니다 (이 도구도 포함)!
- Swift 코드는 Objective-C보다 동적으로 조작하기 어려운 것으로 간주됩니다. 이 라이브러리는 순수 Swift로 작성되었기 때문에 IOSSecuritySuite 메서드가 Objective-C 런타임에 노출되지 않아야 합니다 (우회가 더 어려워집니다 ✅). 공격자가 여전히 MSHookFunction/MSFindSymbol을 사용하여 Swift 심볼을 후킹하고 Swift 코드 실행 흐름을 동적으로 변경할 수 있다는 점을 알아야 합니다.
기여 ❤️
네, 환영합니다! 더 나은 아이디어가 있거나 이 프로젝트를 개선하고 싶다면 Twitter 또는 LinkedIn으로 연락해 주세요. 풀 리퀘스트는 언제나 감사합니다!
특별 감사: 👏🏻
- kubajakowski:
canOpenURL(_:)메서드 문제 지적 - olbartek: 코드 리뷰 및 풀 리퀘스트
- benbahrenburg: 다양한 ISS 개선
- fotiDim: 새로운 파일 경로 추가
- gcharita: Swift Package Manager 지원 추가
- rynaardb:
amIJailbrokenWithFailedChecks()메서드 생성 - undeaDD: 다양한 ISS 개선
- fnxpt: 여러 탈옥 탐지 추가
- TannerJin: MSHook, RuntimeHook, SymbolHook 및 Watchpoint 탐지 모듈
- NikoXu: 파일 무결성 모듈 추가
- hellpf: 댕글링 소켓 문제 수정
- Ant-tree: 후킹 저항성 개선
- izmcm:
amIReverseEngineeredWithFailedChecks()메서드 구현 - sanu: 새로운 파일 검사 제공
- marsepu: 새로운 개선 사항이 포함된 잘 작성된 PR
- mkj-is: ISS 성능 개선 PR 🚄
- LongXiangGuo: 개인정보 매니페스트 추가 PR
- Coeur: ISS 개선 및 버그 수정
- Adobels: 새로운 Apple 요구사항에 맞게 ISS 조정
할 일
- Installer5 및 Zebra 패키지 관리자 탐지 연구 (Cydia 대안)
- Dopamine hidejb 탐지기
라이선스
LICENSE 파일을 참조하세요.
참고 자료
이 도구를 만드는 동안 사용한 자료:
- 🔗 https://github.com/TheSwiftyCoder/JailBreak-Detection
- 🔗 https://github.com/abhinashjain/jailbreakdetection
- 🔗 https://gist.github.com/ddrccw/8412847
- 🔗 https://gist.github.com/bugaevc/4307eaf045e4b4264d8e395b5878a63b
- 📚 David Thiel의 "iOS Application Security"