| name | ios-pentesting-basics |
| description | iOS security testing operations including device identification, shell access, data transfer, app extraction, and decryption. Use this skill whenever the user needs to perform iOS pentesting tasks, identify iOS devices, access device shells, transfer data from iOS devices, extract or decrypt iOS apps, or install apps on iOS devices. Trigger for any iOS security assessment, mobile app testing, or iOS device forensics work. |
iOS Basic Testing Operations
A skill for performing iOS security testing operations including device identification, shell access, data transfer, and app extraction/decryption.
Device Identification
Finding the UDID
The UDID (40-digit unique identifier) is essential for iOS device operations.
Via Finder (macOS Catalina+):
- Connect device via USB
- Open Finder and select the device
- Click the device name to reveal details including UDID
Via iTunes (macOS pre-Catalina):
- Connect device and view in iTunes to find UDID
Command-line methods:
ioreg -p IOUSB -l | grep "USB Serial"
brew install ideviceinstaller
idevice_id -l
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p;/iPhone/,/Serial/p;/iPod/,/Serial/p' | grep "Serial Number:"
instruments -s devices
Device Shell Access
SSH Access (Post-Jailbreak)
- Install OpenSSH package on jailbroken device
- Connect via SSH:
ssh root@<device_ip_address>
- Important: Change default passwords (
alpine for root and mobile users)
SSH Over USB (No Wi-Fi)
Use iproxy to map device ports:
iproxy 2222 22
ssh -p 2222 root@localhost
On-Device Shell Apps
- NewTerm 2: Direct device interaction for troubleshooting
- Reverse SSH shells: Establish remote access from host computer
Password Reset
To reset forgotten passwords to default (alpine):
- Edit
/private/etc/master.passwd
- Replace existing hash with
alpine hash for root and mobile users
Data Transfer
Archive and Transfer via SSH/SCP
tar czvf /tmp/data.tgz /private/var/mobile/Containers/Data/Application/<APP_UUID>
exit
scp -P 2222 root@localhost:/tmp/data.tgz .
GUI Tools
- iFunbox and iExplorer: File management on iOS devices
- Note: iOS 8.4+ restricts access to app sandbox unless jailbroken
Objection for File Management
objection --gadget com.apple.mobilesafari explorer
cd /var/mobile/Containers/Data/Application/<APP_UUID>/Documents
file download <filename>
App Extraction and Decryption
Acquiring IPA Files
OTA Distribution:
npm install -g itms-services
itms-services -u "itms-services://?action=download-manifest&url=<MANIFEST_URL>" -o - > out.ipa
Manual Decryption Process
iOS apps are encrypted with FairPlay. To decrypt:
-
Check and modify PIE flag:
otool -Vh Original_App
python change_macho_flags.py --no-pie Original_App
otool -Vh Hello_World
-
Identify encrypted section:
otool -l Original_App | grep -A 4 LC_ENCRYPTION_INFO
-
Dump memory from jailbroken device:
dump memory dump.bin 0x8000 0x10a4000
4. **Overwrite encrypted section:**
```bash
dd bs=1 seek=<starting_address> conv=notrunc if=dump.bin of=Original_App
- Finalize: Set
cryptid to 0 using MachOView
Automated Decryption Tools
frida-ios-dump
python dump.py -l
python3 dump.py -u "root" -p "<PASSWORD>" <BUNDLE_ID>
Configuration:
- Connect via localhost:2222 (iproxy) or direct IP:port
- Requires jailbroken device with frida-server
frida-ipa-extract
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python extract.py -U -f com.example.app -o MyApp.ipa
python extract.py -H 192.168.100.32 -P 2222 -u root -p password -f com.example.app
python extract.py -U -f com.example.app -o MyApp.ipa --sandbox --no-resume
Flags:
-f <bundle>: Spawn/attach to bundle ID
-o: Output filename
-U: USB mode
-H/-P/-u/-p: SSH tunnel parameters
--sandbox: Dump sandbox
--no-resume: Keep app suspended
flexdecrypt/flexdump
apt install zip unzip
wget https://gist.githubusercontent.com/defparam/71d67ee738341559c35c684d659d40ac/raw/30c7612262f1faf7871ba8e32fbe29c0f3ef9e27/flexdump -P /usr/local/bin
chmod +x /usr/local/bin/flexdump
flexdump list
flexdump dump Twitter.app
bagbak
bagbak --raw Chrome
r2flutch
Radare2 + Frida based decryption tool.
App Installation
Sideloading Methods
Cydia Impactor:
- Sign and install IPA files on iOS
- Also supports APK on Android
libimobiledevice:
ideviceinstaller -i app.ipa
ipainstaller:
- Command-line installation tool
ios-deploy (macOS):
ios-deploy --bundle app.ipa --launch
Xcode:
- Window → Devices and Simulators
- Add app to Installed Apps
Installing iPad Apps on iPhone
Modify Info.plist:
- Change
UIDeviceFamily value to 1
- Re-sign the IPA (signature validation required)
Note: May fail if app requires iPad-exclusive capabilities.
Common Workflows
Full App Extraction Workflow
- Identify device UDID
- Establish SSH connection (via Wi-Fi or iproxy)
- List installed apps
- Extract app using preferred tool (frida-ios-dump, flexdump, etc.)
- Decrypt if necessary
- Transfer to host machine
Data Exfiltration Workflow
- Connect to device shell
- Locate app data directory
- Archive with tar
- Transfer via SCP or objection
Security Considerations
- Always change default passwords after jailbreak
- Use SSH over USB when Wi-Fi is unavailable
- Be aware of iOS version restrictions on tools
- Some tools require specific jailbreak levels
References