iOS Pentesting 无需 Jailbreak
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
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
Main idea
Applications signed with the entitlement get_task_allow allow third party applications to run a function called task_for_pid() with the process ID of the initial application as argument in order to get the task port over it (be able to control it and access it’s memory).
但是,要做到这点并不是简单地拉出 IPA、带上该 entitlement 重新签名然后刷回设备那么容易。这是因为 FairPlay 保护。当应用的签名改变时,DRM (Digital Rights Management) key 会失效,应用将无法运行。
在旧的 jailbroken 设备上,可以安装该 IPA,使用你喜欢的工具解密它(例如 Iridium 或 frida-ios-dump),然后把它从设备上拉出来。不过,如果可能,建议直接使用客户端来获取解密后的 IPA。
Obtain decrypted IPA
Get it from Apple
- 在 iPhone 上安装要 pentest 的应用
- 在你的 macos 中安装并启动 Apple Configurator
- 在你的 Mac 上打开
Terminal,并 cd 到/Users/[username]/Library/Group\\ Containers/K36BKF7T3D.group.com.apple.configurator/Library/Caches/Assets/TemporaryItems/MobileApps。IPA 稍后会出现在这个文件夹中。 - 你应该能看到你的 iOS 设备。双击它,然后从顶部菜单栏点击 Add + → Apps。
- 点击 Add 后,Configurator 会从 Apple 下载 IPA,并尝试推送到你的设备。如果你按我之前的建议已经安装了该 IPA,会出现一个提示,询问你是否要重新安装该应用。
- IPA 应该会被下载到
/Users/[username]/Library/Group\\ Containers/K36BKF7T3D.group.com.apple.configurator/Library/Caches/Assets/TemporaryItems/MobileApps,你可以从那里获取它
Check https://dvuln.com/blog/modern-ios-pentesting-no-jailbreak-needed for more detailed information about this process.
Decrypting the app
为了对 IPA 进行解密,我们需要先安装它。但是,如果你有一台旧的 jailbroken iPhone,可能该设备的系统版本不会被应用支持,因为通常应用只支持最新的版本。
因此,为了安装它,只需解压 IPA:
unzip redacted.ipa -d unzipped
检查 Info.plist 中的最低支持版本,如果你的设备低于该版本,请更改该值以使其受支持。
将 IPA 压缩回去:
cd unzipped
zip -r ../no-min-version.ipa *
然后,例如通过以下命令安装 IPA:
ideviceinstaller -i no-min-version.ipa -w
Note that you might need AppSync Unified tweak from Cydia to prevent any invalid signature errors.
请注意,您可能需要从 Cydia 安装 AppSync Unified tweak 以防止出现任何 invalid signature 错误。
Once intalled, you can use Iridium tweak from Cydia in order to obtain the decrypted IPA.
安装后,您可以从 Cydia 使用 Iridium tweak 来获取解密后的 IPA。
Patch entitlements & re-sign
Patch entitlements & re-sign
In order to re-sign the application with the get-task-allow entitlement there are several tools available like app-signer, codesign, and iResign. app-signer has a very user-friendly interface that allows to very easily resing an IPA file indicating the IPA to re-sign, to put it get-taks-allow and the certificate and provisioning profile to use.
为了使用 get-task-allow entitlement 重新签名应用,有多种工具可用,例如 app-signer、codesign 和 iResign。app-signer 拥有非常友好的界面,可以非常轻松地重新签名 IPA 文件,指定要重新签名的 IPA,put it get-taks-allow,以及要使用的证书和 provisioning profile。
Regarding the certificate and signing profiles, Apple offers free developer signing profiles for all accounts through Xcode. Just create an app and configure one. Then, configure the iPhone to trust the developer apps by navigating to Settings → Privacy & Security, and click on Developer Mode.
关于证书和签名配置文件,Apple 通过 Xcode 为所有帐户提供 free developer signing profiles。只需创建一个应用并配置一个。然后,通过进入 Settings → Privacy & Security,并点击 Developer Mode 来配置 iPhone to trust the developer apps。
With the re-signed IPA, it’s time to install it in the device to pentest it:
有了重新签名的 IPA,就可以将其安装到设备上进行 pentest:
ideviceinstaller -i resigned.ipa -w
IPA patching + DYLIB injection + free Apple ID re-sign (CLI)
如果你已经拥有一个 decrypted IPA,你可以对它打补丁以加载自定义 DYLIB、添加权限(例如 network),并使用免费的 Apple ID 在 without Xcode 的情况下重新签名。 这对于在非越狱设备上进行 in-app instrumentation 非常有用。
典型流程:
# Build the implant (macOS for build step)
make
# Patch the IPA to inject the DYLIB
python3 tools/patcher.py patch --ipa MyApp.ipa --dylib libShell.dylib
# -> MyApp_patched.ipa
# Patch + sign + install in one step (free Apple ID)
python3 tools/patcher.py full \
--ipa MyApp.ipa \
--dylib libShell.dylib \
--apple-id user@example.com \
--install \
--udid <device-udid>
注意:
- 免费 Apple ID 签名通常在 7 天 后过期,并且限制为每周 3 App IDs/week 和 10 sideloaded apps。
- 该工具可以通过 SRP 与 Apple 认证并进行跨平台 re-sign,生成免费的 dev certificate + provisioning profile。Apple 的 anisette headers 按平台处理(macOS 通过
AOSKit.framework,Linux 通过 Anisette.py,Windows 通过外部 anisette server)。 - 这 不会 绕过 sandbox。被注入的代码在应用进程内运行,只能访问应用的 sandbox 和 keychain access groups。
仅通过 USB 访问注入的 implant
如果注入的 DYLIB 暴露了本地 TCP 控制通道,你可以将流量 不通过 Wi-Fi/cellular,并通过 USB 转发:
# Forward device-local TCP port to host
iproxy 8080 8080
# Example client commands (host side)
python3 client.py "ls"
python3 client.py "pwd"
python3 client.py "scp -r Documents host:./downloads"
如果 implant 包含 keychain helpers,你可以转储该 app 可访问的项目:
python3 client.py "keychain dump"
python3 client.py "keychain dump --filter self"
python3 client.py "keychain dump --class generic"
Enable Developer Mode (iOS 16+)
Since iOS 16 Apple introduced Developer Mode: any binary that carries get_task_allow or is signed with a development certificate will refuse to launch until Developer Mode is enabled on the device. You will also not be able to attach Frida/LLDB unless this flag is on.
- 安装或推送任意开发者签名的 IPA 到手机。
- 前往 Settings → Privacy & Security → Developer Mode 并将其开启。
- 设备将重启;输入密码后会提示你 Turn On Developer Mode。
Developer Mode 会保持开启,直到你手动关闭或抹掉手机,因此每台设备只需执行一次此操作。 Apple documentation explains the security implications.
Modern sideloading options
There are now several mature ways to sideload and keep re-signed IPAs up-to-date without a jailbreak:
| 工具 | 要求 | 优点 | 限制 |
|---|---|---|---|
| AltStore 2 / SideStore | 需要 macOS/Windows/Linux 的 companion,使用免费 dev profile 每 7 天重新签名 IPA | 支持通过 Wi‑Fi 自动重载,支持到 iOS 17 | 需要同一网络上的电脑,受 Apple 强制的 3-app 限制 |
| TrollStore 1/2 | 设备需为受 CoreTrust bug 影响的 iOS 14 – 15.4.1 | Permanent signing(无 7 天限制);安装后无需电脑 | 不支持 iOS 15.5+(bug 已修补) |
For routine pentests on current iOS versions Alt/Side-Store are usually the most practical choice.
Hooking / dynamic instrumentation
You can hook your app exactly as on a jailbroken device once it is signed with get_task_allow and Developer Mode is on:
# Spawn & attach with objection
objection -g "com.example.target" explore
# Or plain Frida
frida -U -f com.example.target -l my_script.js --no-pause
最近的 Frida 版本 (>=16) 会自动处理 pointer authentication 以及其他 iOS 17 的缓解措施,因此大多数现有脚本可以开箱即用。
Frida Gadget 注入到 non-jailbroken IPAs (listen mode)
如果你能 modify and re-sign an IPA,你可以嵌入 Frida Gadget 并修补 Mach-O,使其在启动时通过 @rpath 加载。这样可以在没有 jailbreak 的情况下使用 Frida/Objection(设备必须接受 re-signed IPA)。
一个实用的工作流程是使用 GadgetInjector(Python 工具)注入 FridaGadget.dylib 并生成一个 listen-mode 配置:
python3 gadget_injector.py MyApp.ipa
# Output: MyApp-frida-listen.ipa
重新签名 约束(重要,适用于未越狱的安装):
- 签名 所有嵌入的 dylibs 并使用 相同的 Team ID。
- 不要 向
FridaGadget.dylib添加额外的 entitlements。
重新签名并安装 IPA 后,以 listen 模式 attach:
# (Optional) start the app paused
xcrun devicectl device process launch \
--device <UDID> \
--start-stopped <bundle-id>
# Forward Frida listen port over USB (default 27042)
pymobiledevice3 usbmux forward 27042 27042
# Objection
objection -g <bundle-id> explore
# Or Frida CLI
frida -H 127.0.0.1:27042 -n MyApp
使用 MobSF 进行自动化动态分析 (no jailbreak)
MobSF 可以利用相同的技术(get_task_allow)在真实设备上对 dev-signed IPA 进行注入以启用调试,并提供带有文件系统浏览器、流量捕获和 Frida 控制台的 web UI【】。最快的方法是在 Docker 中运行 MobSF,然后通过 USB 将 iPhone 连接上:
docker pull opensecurity/mobile-security-framework-mobsf:latest
docker run -p 8000:8000 --privileged \
-v /var/run/usbmuxd:/var/run/usbmuxd \
opensecurity/mobile-security-framework-mobsf:latest
# Browse to http://127.0.0.1:8000 and upload your resigned IPA
MobSF 会自动部署二进制、在应用沙箱内启动 Frida server 并生成交互式报告。
iOS 17 & Lockdown Mode 注意事项
- Lockdown Mode (Settings → Privacy & Security) 会阻止动态链接器加载未签名或外部签名的动态库。测试可能启用此模式的设备时,确保其已禁用,否则你的 Frida/objection 会话会立即终止。
- Pointer Authentication (PAC) 在 A12+ 设备上作为系统级别强制执行。Frida ≥16 能透明地处理 PAC stripping —— 当出现新的主版本 iOS 时,只需保持 frida-server 和 Python/CLI toolchain 都是最新的。
参考资料
- https://dvuln.com/blog/modern-ios-pentesting-no-jailbreak-needed
- Apple 开发者文档 – 在设备上启用开发者模式: https://developer.apple.com/documentation/xcode/enabling-developer-mode-on-a-device
- Mobile Security Framework (MobSF): https://mobsf.github.io/Mobile-Security-Framework-MobSF/
- https://github.com/test1ng-guy/iOS-sandbox-explorer
- https://github.com/Saurabh221662/GadgetInjector
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
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。


