iOS Burp Suite 配置

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

在 iOS 设备上安装 Burp 证书

为了对 iOS 设备上的 Web 流量进行安全分析并处理 SSL pinning,可以使用 Burp Suite,通过 Burp Mobile Assistant 自动安装,或通过手动配置。下面对两种方法做了简要说明:

使用 Burp Mobile Assistant 自动安装

Burp Mobile Assistant 简化了 Burp 证书、代理配置和 SSL Pinning 的安装流程。详细指南见 PortSwigger’s official documentation

手动安装步骤

  1. 代理配置: 首先在 iPhone 的 Wi‑Fi 设置中将 Burp 设为代理。
  2. 证书下载: 在设备浏览器中访问 http://burp 下载证书。
  3. 证书安装: 通过 Settings > General > VPN & Device Management 安装下载的配置文件,然后在 Certificate Trust Settings 中为 PortSwigger CA 启用信任。

配置拦截代理

该配置允许通过 Burp 对 iOS 设备与互联网之间的流量进行分析,要求 Wi‑Fi 网络支持客户端互通。如果不可用,可以通过 usbmuxd 使用 USB 连接作为替代。PortSwigger’s tutorials 提供了关于 device configurationcertificate installation 的详细说明。

通过 OpenVPN + iptables REDIRECT 进行透明代理

如果目标应用忽略已配置的 HTTP 代理,可以将 iOS 设备置于一个 研究人员控制的 VPN 网关 后面,并将流量透明地重定向到 Burp 或 mitmproxy

这本身并不是对 certificate pinning 的绕过。它仅解决网络传输问题,使设备流量在不为单个应用或设备配置代理的情况下到达你的拦截代理。如果应用实施了真实的 certificate pinning,HTTPS 解密仍会失败,直到另外绕过 pinning。

典型流程:

  1. 在 Linux 主机上运行 OpenVPN 服务器,并将 iOS 设备连接到该服务器,使其流量到达 tun0
  2. 将 Burp 或 mitmproxy 绑定到 VPN 监听 IP 的端口 8080
  3. 在 Burp 中启用 invisible proxying,因为被重定向的客户端不知道代理的存在,会像直接连接目标那样发起请求。
  4. 将到达 tun0 的 TCP 端口 80443 的流量重定向到本地代理监听端口。
  5. 在出口接口上添加 POSTROUTINGMASQUERADE 规则,使代理后的流量能够离开网关,并通过 VPN 返回响应。
  6. 在 iOS 设备上安装并信任拦截代理的 CA,这样仅依赖系统信任存储的应用才会接受生成的 leaf 证书。

示例规则:

# Redirect VPN client traffic into the local interception proxy
iptables -t nat -A PREROUTING -i tun0 -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -i tun0 -p tcp --dport 443 -j REDIRECT --to-ports 8080

# Allow VPN client traffic to egress back to the Internet
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

注意:

  • 当你想要 forced interception 且不修改目标应用或在 iOS Wi‑Fi 设置中配置显式代理时,这很有用。
  • 443 重定向到 Burp 仅适用于信任已安装 CA 的应用,或已绕过 TLS 验证/证书固定(pinning)的应用。
  • 上游仓库的示例脚本会在 POSTROUTING 规则中将 IP 添加 /24。在实际操作中,应使用 实际的 VPN 客户端子网,而不要假设固定的 /24
  • 如果使用 Burp,启用 Proxy –> Options –> Edit listener –> Request handling –> Support invisible proxying
  • mitmproxy 可以在相同布局下使用,前提是它绑定到 VPN 侦听器 IP 并满足透明模式的要求。

越狱设备的高级配置

对于越狱设备用户,通过 USB 使用 SSH(通过 iproxy)提供了一种将流量直接路由到 Burp 的方法:

  1. 建立 SSH 连接: 使用 iproxy 将 SSH 转发到 localhost,使 iOS 设备能够连接到运行 Burp 的计算机。
iproxy 2222 22
  1. 远程端口转发: 将 iOS 设备的 8080 端口转发到计算机的 localhost,以便直接访问 Burp 的界面。
ssh -R 8080:localhost:8080 root@localhost -p 2222
  1. 全局代理设置: 最后,在 iOS 设备的 Wi‑Fi 设置中配置手动代理,将所有网页流量通过 Burp 转发。

全网络监控/嗅探

非 HTTP 设备流量的监控可以使用 Wireshark 高效进行,Wireshark 能捕获各种形式的数据流量。对于 iOS 设备,实时流量监控通过创建 Remote Virtual Interface 实现,具体过程请参见 这篇 Stack Overflow 帖子。开始之前,需要先在 macOS 系统上安装 Wireshark

该过程涉及几个关键步骤:

  1. 通过 USB 在 iOS 设备和 macOS 主机之间建立连接。
  2. 确定 iOS 设备的 UDID,这是进行流量监控的必要步骤。可以在 macOS Terminal 中执行以下命令完成:
$ rvictl -s <UDID>
Starting device <UDID> [SUCCEEDED] with interface rvi0
  1. 在识别出 UDID 之后,打开 Wireshark,并选择 “rvi0” 接口进行数据捕获。
  2. 对于有针对性的监控(例如捕获与特定 IP 地址相关的 HTTP 流量),可以使用 Wireshark 的 Capture Filters:

Burp Cert Installation in Simulator

  • Export Burp Certificate

In Proxy –> Options –> Export CA certificate –> Certificate in DER format

  • Drag and Drop 将证书拖放到模拟器内
  • Inside the emulator 进入 Settings –> General –> Profile –> PortSwigger CA,并验证证书
  • Inside the emulator 进入 Settings –> General –> About –> Certificate Trust Settings,并启用 PortSwigger CA

Congrats, you have successfully configured the Burp CA Certificate in the iOS simulator

Tip

iOS 模拟器将使用 MacOS 的代理配置。

MacOS Proxy Configuration

Steps to configure Burp as proxy:

  • Go to System Preferences –> Network –> Advanced
  • In Proxies tab mark Web Proxy (HTTP) and Secure Web Proxy (HTTPS)
  • In both options configure 127.0.0.1:8080

  • 点击 Ok 然后点击 Apply

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