|
| 1 | +--- |
| 2 | +date: 2025-09-25 22:03:15 |
| 3 | +layout: post |
| 4 | +title: iOS All The Things - Part II |
| 5 | + |
| 6 | +description: |
| 7 | +image: /assets/img/ios-pentesting/Part-II/cover-test.jpeg |
| 8 | +optimized_image: /assets/img/ios-pentesting/Part-II/cover-test.jpeg |
| 9 | +category: blog |
| 10 | +tags: |
| 11 | + - iOS Pentesting |
| 12 | + - IOS Penetration Testing |
| 13 | + - jailbreak |
| 14 | + - burpsuite on ios |
| 15 | + - iOS Basics |
| 16 | +--- |
| 17 | + |
| 18 | +# Agenda of iOS Pentesting: |
| 19 | +1. [Intro](#intro) |
| 20 | +2. [Types of Jailbreaking](#types-of-jailbreaking) |
| 21 | +3. [Pull & Push IPA Packages](#pull--push-ipa-packages) |
| 22 | +4. [Setup BurpSuite](#setup-burpsuite) |
| 23 | +5. [Tools](#tools) |
| 24 | +6. [Conclusion](#conclusion) |
| 25 | + |
| 26 | +## Intro |
| 27 | +Before we can start using advanced penetration testing tools on an actual iPhone, we need to address a fundamental barrier: Apple's strict security controls. These controls, while great for user safety, limit our ability to inspect a running system. This is where jailbreaking comes in. |
| 28 | + |
| 29 | +**Jailbreaking** is the process of removing these software restrictions imposed by Apple. It gives you root access (administrator-level control) to the iOS operating system. This allows you to: |
| 30 | + |
| 31 | +* Install applications from outside the official App Store. |
| 32 | +* Customize the operating system's look and feel. |
| 33 | +* Most importantly for us: Run powerful security tools that can analyze other apps and the system itself. |
| 34 | + |
| 35 | +**Jailbreaking** exploits vulnerabilities (security weaknesses) in the iOS code to bypass Apple's security layers. The goal is always the same: to break the "chain of trust" and gain the ability to run unsigned code. |
| 36 | + |
| 37 | +The general process can be summarized in the following chart: |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +Here’s the breakdown: |
| 42 | + |
| 43 | +a. **Exploit a Vulnerability:** The jailbreak tool uses a specific bug or combination of bugs in the iOS software. These can be in the web browser (a "browser-based" exploit) or in a file the device opens. |
| 44 | + |
| 45 | +b. **Bypass Security Protections:** The exploit is used to bypass the two main security features: |
| 46 | + |
| 47 | + * Code Signing: This allows the device to run the jailbreak's own code, which is not signed by Apple. |
| 48 | + * Sandbox: This escapes the app's restricted container, giving the code access to the entire filesystem. |
| 49 | + |
| 50 | +c. **Patch the Kernel:** The "kernel" is the core of the operating system. The jailbreak modifies it in memory to permanently disable the security checks (like code signing enforcement) while the device is running. |
| 51 | + |
| 52 | +d. **Install Persistence and a Package Manager:** Finally, the tool installs a "package manager" like Cydia or Sileo. This is an alternative app store specifically for installing tweaks and command-line tools (like those we need for pentesting). It also adds a helper to re-apply the jailbreak after a device reboot (since the kernel patches are not permanent by default). |
| 53 | + |
| 54 | +For a penetration tester, a jailbroken device is a laboratory. It is the equivalent of having administrative access on a target server. It allows us to: |
| 55 | + |
| 56 | +* Intercept network traffic (SSL Pinning). |
| 57 | +* Analyze and modify app data at runtime. |
| 58 | +* Dump decrypted application binaries for static analysis. |
| 59 | +* See the real-time behavior of the operating system. |
| 60 | + |
| 61 | +## Types of Jailbreaking |
| 62 | + |
| 63 | +Not all jailbreaks are created equal. The main difference between them lies in what happens when you restart the device. This characteristic of the jailbreak's ability to survive a reboot. It is categorized into four main types. |
| 64 | + |
| 65 | +The following chart illustrates how each type behaves during a device reboot: |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +Here’s the breakdown: |
| 70 | + |
| 71 | +a. **UnTethered:** if reboot the device, the ios is still jailbreaking. |
| 72 | + |
| 73 | +b. **Tethered:** if reboot the device, the ios is return to normal status(means not jailbreak). |
| 74 | + |
| 75 | +c. **Semi-Tethered:** This type of jailbreak allows a user to reboot their phone normally, but upon doing so, the jailbreak and any modified code will be effectively disabled, as it will have an unpatched kernel. (need to do re-jailbreak because not open in optima stage in jailbreak). |
| 76 | + |
| 77 | +d. **Semi-Untethered:** if reboot the device , the ios is return to normal status but the device have ipa package can use it to do jailbreak again without using any cables. |
| 78 | + |
| 79 | +> **Important Tip:** A semi-untethered jailbreak is often the best choice because it allows for maximum flexibility. If your testing causes a device crash and reboot, you can quickly re-enable the jailbreak directly from the device without needing to be near a computer, ensuring you can get back to work quickly. |
| 80 | +
|
| 81 | +Using that [website](https://canijailbreak.com/) to know what’s that tool compatible with version of ios device to make jailbreak. |
| 82 | + |
| 83 | +## Pull & Push IPA Packages |
| 84 | + |
| 85 | +Once your iOS device is successfully jailbroken, the next step is to install a package manager like Sileo, Cydia, or Zebra. Think of this as an "alternative App Store" specifically for jailbroken devices, where you can find powerful tools and tweaks that Apple doesn't allow. |
| 86 | + |
| 87 | +One of the most important tools you can install is Filza File Manager. This is a powerful file explorer that gives you full access to the entire iOS filesystem. something that is normally restricted on a non-jailbroken device. |
| 88 | + |
| 89 | +**Filza Uses:** |
| 90 | +* Browse System Files: View and edit files across the entire operating system. |
| 91 | +* Access App Containers: Open the sandboxed directories of installed applications. |
| 92 | +* Extract IPA Files: This is a critical function for penetration testers. |
| 93 | + |
| 94 | +#### How to Extract an IPA using Filza |
| 95 | + |
| 96 | +Another meaning pull any installed app from your device for analysis: |
| 97 | + |
| 98 | +a. Open Filza and navigate to the applications directory: '/var/containers/Bundle/Application/' |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +b. Find the App: You'll see folders with random names. Open each one to find the '.app' bundle for your target application (e.g., Facetime.app). |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +c. Go to any directory, such as /var/mobile/Downloads. Create a new folder named Payload. Paste the copied '.app' bundle into this Payload folder. |
| 107 | + |
| 108 | +d. Compress the Payload folder into a ZIP file. Long-press on the Payload folder and select the "Compress" option. This will create a Payload.zip file. |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +e. Rename the Payload.zip file to YourAppName.ipa. An IPA file is essentially a standard ZIP archive with a specific structure and a different file extension. |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +f. The '.ipa' file is now ready for analysis. You can transfer it to your own machine (e.g., Kali Linux system) using a secure transfer tool like scp (Secure Copy). |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +To move the extracted IPA file from your iOS device to your computer, you need a connection between the two devices. This is typically done using SSH (Secure Shell). |
| 121 | + |
| 122 | +* **Method 1:** Using SSH from Your Computer |
| 123 | + |
| 124 | + Ensure SSH is enabled on your jailbroken iOS device and that both devices are on the same network. |
| 125 | + |
| 126 | + ```bash |
| 127 | + scp mobile@[device_ip]:/var/mobile/Documents/YourAppName.ipa /path/on/your/kali/ |
| 128 | + ``` |
| 129 | + |
| 130 | +* **Method 2:** Using NewTerm on Your iOS Device |
| 131 | + |
| 132 | + Alternatively, you can use NewTerm (available in Sileo/Zebra) a terminal emulator for iOS. to push the file to your computer: |
| 133 | + |
| 134 | + a. Install NewTerm from your package manager. |
| 135 | + |
| 136 | + b. Open NewTerm and use scp in reverse: |
| 137 | + |
| 138 | + ```bash |
| 139 | + scp /var/mobile/Downloads/YourAppName.ipa kali@[KALI_IP]:/home/kali/Downloads/ |
| 140 | + |
| 141 | + // The same scp command can also be used to transfer an IPA package from your computer to your jailbroken device (Push) |
| 142 | + scp /home/kali/Downloads/YourAppName.ipa mobile@[device_ip]:/var/mobile/Downloads/ |
| 143 | + ``` |
| 144 | + |
| 145 | +This ability to extract IPAs directly from a jailbroken device is a game-changer for security testing. It allows you to: |
| 146 | + |
| 147 | +* Perform static analysis on real applications using tools like Ghidra or Hopper. |
| 148 | +* Study the app’s compiled code, configuration files, and resources. |
| 149 | +* Identify potential vulnerabilities without needing the original source code. |
| 150 | + |
| 151 | +#### Analyzing Decrypted Executables with Hopper or Ghidra |
| 152 | + |
| 153 | +After transferring an IPA package to your computer, the next step is to analyze the application's main executable file. You can extract this file by unzipping the IPA package and navigating to the 'Payload/YourApp.app' folder. |
| 154 | + |
| 155 | +When you try to analyze an App Store application using reverse engineering tools like Hopper or Ghidra, you'll encounter a significant obstacle: the main executable file is encrypted. Apple encrypts applications from the App Store to protect intellectual property, which means static analysis tools will show garbled or meaningless code. |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | +When an iOS application runs, the system must decrypt it in memory to execute the code. |
| 160 | + |
| 161 | +To overcome this encryption barrier, we use 'frida-ios-dump' a powerful tool that captures a running application directly from the device's memory. Here's how it works: |
| 162 | + |
| 163 | +a. Install frida-server from sileo. |
| 164 | + |
| 165 | +b. Run the target application on your jailbroken device. |
| 166 | + |
| 167 | +c. Execute [frida-ios-dump](https://github.com/AloneMonkey/frida-ios-dump) from your computer while the app is active. |
| 168 | + |
| 169 | +```bash |
| 170 | +// to forward ssh connection |
| 171 | +iproxy 2222 22 |
| 172 | +// run frida-ios-dump |
| 173 | +./dump.py -H device-ip -u user -P password -p 2222 (bundle/name) |
| 174 | +``` |
| 175 | + |
| 176 | +d. The tool dumps the decrypted version of the application from memory. |
| 177 | + |
| 178 | +e. You now have a decrypted IPA that can be properly analyzed. |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | +## Setup BurpSuite |
0 commit comments