iOS 테스트 환경

Tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기

Apple Developer Program

A provisioning identity는 Apple 개발자 계정과 연관된 공개키와 개인키들의 모음입니다. 앱에 sign하려면 Apple Developer Program에 등록하고 99$/year를 지불해 provisioning identity를 얻어야 합니다. 이 과정이 없으면 물리 기기에서 소스 코드로부터 애플리케이션을 실행할 수 없습니다. 다른 방법으로는 jailbroken device를 사용하는 것이 있습니다.

Xcode 7.2부터 Apple은 실제 iPhone에서 애플리케이션을 작성하고 테스트할 수 있는 free iOS development provisioning profile을 생성하는 옵션을 제공했습니다. Xcode –> Preferences –> Accounts –> + (새로운 Apple ID를 자격 증명으로 추가) –> Click on the Apple ID created –> Manage Certificates –> + (Apple Development) –> Done
__그런 다음, iPhone에서 애플리케이션을 실행하려면 먼저 iPhone에 컴퓨터를 신뢰하도록 표시해야 합니다. 그 후 Xcode에서 모바일에서 애플리케이션을 실행해 볼 수 있지만 오류가 발생합니다. 따라서 Settings –> General –> Profiles and Device Management –> 신뢰되지 않은 프로필을 선택하고 “Trust“를 클릭하세요.

On iOS 16+, Developer Mode는 로컬에 설치된 개발 서명된 애플리케이션(또는 get-task-allow로 다시 서명된 앱)이 실행되기 전에 기기에서 활성화되어야 합니다. 이 옵션은 기기를 Xcode와 페어링한 후 또는 개발 서명된 앱을 한 번 설치한 후에만 나타납니다. 흐름은: 기기 페어링, Xcode에서 설치 트리거, 그런 다음 Settings –> Privacy & Security –> Developer Mode를 활성화하고 재부팅한 뒤 잠금 해제 후 프롬프트를 확인하는 것입니다.

동일한 서명 인증서로 서명된 applications는 keychain items와 같은 리소스를 안전하게 공유할 수 있다는 점을 유의하세요.

The provisioning profiles are stored inside the phone in /Library/MobileDevice/ProvisioningProfiles

최신 호스트 측 디바이스 도구

현재 iOS 테스트를 위해 호스트 측 도구는 점점 다음으로 분리되고 있습니다:

  • xcrun simctl for simulator management
  • xcrun xctrace list devices to enumerate simulators and physical devices
  • xcrun devicectl (Xcode 15+) to interact with paired physical devices from the command line

유용한 예:

# List booted simulators
xcrun simctl list | grep Booted

# List all visible devices/simulators
xcrun xctrace list devices

# List paired physical devices (Xcode 15+)
xcrun devicectl list devices

devicectl은 Xcode를 열지 않고 테스트 빌드를 설치하거나 실행해야 하는 자동화 파이프라인에서 특히 유용합니다:

xcrun devicectl device install app --device <udid> <path_to_app_or_ipa>
xcrun devicectl device launch app --terminate-existing --device <udid> <bundle_id>

Keep Xcode updated when testing iOS 17+ devices. Apple moved developer services to the CoreDevice stack and also changed how Developer Disk Images are handled, so outdated host tooling frequently fails with pairing, image-mounting, or app-launch errors.

Simulator

Tip

Note that a simulator isn’t the same as en emulator. The simulator just simulates the behaviour of the device and functions but don’t actually use them.

Simulator

가장 먼저 알아둘 점은 simulator 내부에서 pentest를 수행하는 것은 jailbroken device에서 수행하는 것보다 훨씬 제한적이라는 것입니다.

iOS 앱을 빌드하고 지원하는 데 필요한 모든 도구는 only officially supported on Mac OS입니다.
iOS 애플리케이션을 생성/디버깅/계측하는 사실상의 도구는 Xcode입니다. Xcode는 simulators나 빌드 및 test에 필요한 다양한 SDK versions와 같은 다른 구성요소를 다운로드하는 데 사용할 수 있습니다.
Xcode는 official App Store에서 download하는 것을 강력히 권장합니다. 비공식 버전은 malware를 포함할 수 있습니다.

The simulator files can be found in /Users/<username>/Library/Developer/CoreSimulator/Devices

Simulator는 여전히 filesystem artifacts, NSUserDefaults, plist parsing, custom URL schemes, 및 basic runtime instrumentation을 빠르게 테스트하는 데 매우 유용합니다. 그러나 simulator는 pentest 시 자주 관련되는 여러 물리적 기기 보안 속성들을 에뮬레이트하지 않는다는 점을 염두에 두어야 합니다. 예를 들어 Secure Enclave, baseband, 특정 keychain access-control behaviours, 현실적인 biometric flows, 및 jailbreak-specific 실행 조건 등이 있습니다.

To open the simulator, run Xcode, then press in the Xcode tab –> Open Developer tools –> Simulator
__In the following image clicking in “iPod touch […]” you can select other device to test in:

Applications in the Simulator

Inside /Users/<username>/Library/Developer/CoreSimulator/Devices you may find all the installed simulators. If you want to access the files of an application created inside one of the emulators it might be difficult to know in which one the app is installed. A quick way to find the correct UID is to execute the app in the simulator and execute:

xcrun simctl list | grep Booted
iPhone 8 (BF5DA4F8-6BBE-4EA0-BA16-7E3AFD16C06C) (Booted)

Once you know the UID the apps installed within it can be found in /Users/<username>/Library/Developer/CoreSimulator/Devices/{UID}/data/Containers/Data/Application

However, surprisingly you won’t find the application here. You need to access /Users/<username>/Library/Developer/Xcode/DerivedData/{Application}/Build/Products/Debug-iphonesimulator/

And in this folder you can find the package of the application.

Emulator

Corellium is the only publicly available iOS emulator. It is an enterprise SaaS solution with a per user license model and does not offer any trial license.

No Jailbreak needed

다음 블로그 포스트를 확인하세요 — non jailbroken device에서 iOS 애플리케이션을 어떻게 pentest하는지에 대한 내용입니다:

iOS Pentesting withuot Jailbreak

Jailbreaking

Apple은 iPhone에서 실행되는 코드가 Apple이 발급한 인증서로 서명되어야 한다고 엄격히 요구합니다. Jailbreaking은 이러한 제한과 OS가 적용한 다른 보안 제어를 적극적으로 우회하는 과정입니다. 따라서 디바이스가 jailbroken 상태가 되면, 설치된 앱을 검증하는 역할을 하는 **무결성 검사(integrity check)**가 패치되어 **우회(bypassed)**됩니다.

Tip

Unlike Android, you cannot switch to “Developer Mode” in iOS to run unsigned/untrusted code on the device.

Android Rooting vs. iOS Jailbreaking

비교되는 경우가 많지만, Android의 rooting과 iOS의 jailbreaking은 근본적으로 다른 과정입니다. Android에서의 rooting은 su 바이너리 설치rooted custom ROM으로 시스템 교체를 포함할 수 있으며, 부트로더가 잠금 해제되어 있다면 반드시 익스플로잇이 필요하지는 않습니다. Flashing custom ROMs는 부트로더를 언락한 후 기기의 OS를 교체하는 작업으로, 때로는 익스플로잇이 요구되기도 합니다.

반대로, iOS 디바이스는 부트로더가 Apple 서명 이미지만 부팅하도록 제한되어 있어 커스텀 ROM을 플래시할 수 없습니다. Jailbreaking iOS는 Apple의 코드 서명 보호를 우회하여 서명되지 않은 코드를 실행하게 하는 것을 목표로 하며, Apple의 지속적인 보안 강화로 인해 복잡한 과정입니다.

Jailbreaking Challenges

Apple이 취약점을 빠르게 패치하기 때문에 iOS 탈옥은 점점 더 어려워지고 있습니다. iOS 다운그레이드는 릴리스 후 제한된 시간 동안만 가능해 jailbreaking은 시간적으로 민감한 작업이 됩니다. 보안 테스트에 사용하는 디바이스는 재탈옥이 보장되지 않는 한 업데이트하지 않는 것이 좋습니다.

iOS 업데이트는 challenge-response 메커니즘(SHSH blobs)에 의해 제어되어 Apple이 서명한 응답만 설치를 허용합니다. 이 메커니즘은 소위 “signing window“로 알려져 있으며, OTA 펌웨어 패키지를 저장해 두었다가 나중에 사용하는 것을 제한합니다. 현재 signing window를 확인하려면 IPSW Downloads website를 참고하세요.

Jailbreak Varieties

  • Tethered jailbreaks require a computer connection for each reboot.
  • Semi-tethered jailbreaks allow booting into non-jailbroken mode without a computer.
  • Semi-untethered jailbreaks require manual re-jailbreaking without needing a computer.
  • Untethered jailbreaks offer a permanent jailbreak solution without the need for re-application.

Jailbreaking Tools and Resources

Jailbreaking 도구는 iOS 버전과 기기별로 다릅니다. 최신 정보를 제공하는 리소스는 Can I Jailbreak?, The iPhone Wiki, Reddit Jailbreak 등이 있습니다. 예시로는:

  • Checkra1n for older A7-A11/iOS 12-14 era research devices.
  • Palera1n for checkm8-compatible devices (A8-A11) on iOS/iPadOS 15+.
  • Dopamine for many arm64/arm64e devices on iOS 15/16 using a modern rootless jailbreak.
  • Unc0ver remains relevant mainly for older iOS versions up to 14.8.

기기를 수정하는 작업에는 위험이 따르므로 jailbreaking은 신중히 접근해야 합니다.

Rootless jailbreaks

현대의 iOS 15+ jailbreak들은 일반적으로 rootless 방식이며, 과거의 rootful 방식과는 다릅니다. 테스터 관점에서 이는 중요한 차이로, 많은 오래된 가이드가 jailbreak 파일이 루트(/) 또는 /Library/...에 직접 존재한다고 가정하는데, 이는 최신 설정에서는 더 이상 사실이 아닙니다.

  • Rootless jailbreaks는 봉인된 시스템 볼륨을 직접 수정하지 않습니다.
  • palera1n에서는 jailbreak 파일이 일반적으로 /private/preboot/...의 무작위 경로에 저장되며 안정적인 심볼릭 링크 **/var/jb**를 통해 노출됩니다.
  • 따라서 tweaks, launch daemons, helper binaries는 이전의 rootful 위치 대신 /var/jb 아래에 존재할 수 있습니다.

이는 environment validation, Frida setup, 그리고 jailbreak detection bypass에 직접적인 영향을 미칩니다:

  • 툴링이 제대로 설치되었는지 확인할 때는 레거시 경로와 /var/jb 둘 다 검사하세요.
  • 앱의 jailbreak detection 로직을 검토할 때는 현대의 검사들이 Cydia.app 같은 고전적 지표 외에도 rootless 아티팩트와 /private/preboot/...로의 심볼릭 링크를 확인하는 경우가 많다는 점을 기억하세요.
  • 타사 스크립트나 tweak가 rootful 파일 시스템 레이아웃을 가정하면 rootless 디바이스에서 조용히 실패할 수 있습니다.

Jailbreaking Benefits and Risks

Jailbreaking은 OS가 부과한 **샌드박스(sandboxing)**를 제거하여 앱이 전체 파일 시스템에 접근할 수 있게 합니다. 이로 인해 승인되지 않은 앱 설치 및 더 많은 API 접근이 가능해집니다. 그러나 일반 사용자에게는 보안 위험과 기기 불안정성을 초래할 수 있으므로 권장되지 않습니다.

After Jailbreaking

iOS Basic Testing Operations

Jailbreak Detection

Several applications will try to detect if the mobile is jailbroken and in that case the application won’t run

  • After jailbreaking an iOS files and folders are usually installed, these can be searched to determine if the device is jailbroken.
  • In modern rootless jailbreaks, those files may appear under /var/jb or resolve through symlinks into /private/preboot/... instead of only in classic rootful locations.
  • In a jailbroken device applications get read/write access to new files outside the sandbox
  • Some API calls will behave differently
  • The presence of the OpenSSH service
  • Calling /bin/sh will return 1 instead of 0

More information about how to detect jailbreaking here.

You can try to avoid this detections using objection’s ios jailbreak disable

Jailbreak Detection Bypass

  • You can try to avoid this detections using objection’s ios jailbreak disable
  • You could also install the tool Liberty Lite (https://ryleyangus.com/repo/). Once the repo is added, the app should appear in the ‘Search’ tab

References

Tip

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE) Azure 해킹 배우기 및 연습하기: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks 지원하기