HomeAbdullah Diaa

How to Intercept iPhone Traffic for Mobile Applications that Bypass Proxy Settings

#ios
#security
#networking
#reverse-engineering
#tutorial
Abdullah Diaa

Abdullah Diaa

6 min read
How to Intercept iPhone Traffic for Mobile Applications that Bypass Proxy Settings

Many iOS applications intentionally bypass system proxy settings for security reasons or to prevent traffic inspection. This guide demonstrates how to set up transparent proxying on macOS to intercept HTTPS traffic from iOS apps that ignore proxy configurations, useful for legitimate security testing, app debugging, and API analysis on your own devices.

⚠️ Important Legal Notice
This technique should only be used on devices you own for legitimate purposes such as:
  • Debugging your own applications
  • Security testing with proper authorization
  • Educational research in controlled environments
  • Understanding API behavior for apps you're developing integrations with

Why Apps Bypass Proxy Settings

📱 How Apps Bypass Proxies
Modern mobile applications often bypass proxy settings by:
  • Using low-level networking APIs that ignore system proxy configuration
  • Implementing certificate pinning
  • Using custom network stacks
  • Hardcoding direct connections to servers

This guide uses a transparent proxy approach that intercepts traffic at the network level, making it invisible to the application.

Prerequisites

✅ What You'll Need
  • A Mac running macOS
  • An iPhone (that you own or have permission to test)
  • mitmproxy installed on your Mac (brew install mitmproxy)
  • Administrator access on your Mac
  • USB cable for iPhone connection

Step 1: Install the mitmproxy Certificate on Your iPhone

First, configure your iPhone to trust mitmproxy's certificate authority:

  1. Start mitmproxy on your Mac:

    mitmproxy --listen-port 8889
    
  2. On your iPhone, open Safari and navigate to `mitm.it`

  3. Follow the iOS installation instructions to download the certificate profile

  4. Install the profile:

    • Go to Settings → General → Profile & Device Management
    • Tap on the mitmproxy profile and install it
  5. Enable full trust for the certificate:

    • Navigate to Settings → General → About → Certificate Trust Settings
    • Toggle on "Enable full trust" for the mitmproxy root certificate

Step 2: Configure Internet Sharing via USB

Set up your Mac to share its internet connection with your iPhone:

  1. Connect your iPhone to your Mac using a USB cable

  2. On your Mac, open System Preferences → Sharing

  3. Click the info button (ⓘ) next to "Internet Sharing"

mitmproxy capturing iPhone traffic
  1. Configure sharing settings:

    • Share your connection from: Wi-Fi
    • To computers using: iPhone USB (check this option)
mitmproxy capturing iPhone traffic
  1. Enable Internet Sharing by checking the main checkbox
mitmproxy capturing iPhone traffic

This creates a network bridge interface on your Mac that will handle all iPhone traffic.

Step 3: Identify the Bridge Interface

💡 Tip
When Internet Sharing is activated, macOS creates a bridge interface. To locate it:
/sbin/ifconfig | grep -A 5 bridge

Look for an interface named `bridge100` or similar with an IP address (typically `192.168.2.1`):

bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether fa:4d:89:96:7d:64
    inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
    inet6 fe80::f84d:89ff:fe96:7d64%bridge100 prefixlen 64 scopeid 0x1e

Verify that traffic is flowing through this interface:

sudo /usr/sbin/tcpdump -i bridge100

You should see packet activity when using your iPhone.

Step 4: Configure macOS Packet Filter for Transparent Redirection

Configure the packet filter to redirect all TCP traffic to mitmproxy:

  1. Open the packet filter configuration file:

    sudo vim /etc/pf.conf
    
  2. Add this redirection rule in the correct position:

    rdr on bridge100 inet proto tcp from any to any -> 127.0.0.1 port 8889
    
    ⚡ Placement
    This line must be placed:
    • AFTER any rdr-anchor "com.apple/*" lines
    • BEFORE any dummynet-anchor lines
  3. Reload the packet filter configuration:

    sudo /sbin/pfctl -f /etc/pf.conf
    
  4. Enable IP forwarding to allow traffic passthrough:

    sudo /usr/sbin/sysctl -w net.inet.ip.forwarding=1
    

Step 5: Launch mitmproxy in Transparent Mode

Start mitmproxy with transparent mode enabled:

mitmweb --mode transparent --listen-host 127.0.0.1 --listen-port 8889

Success! You Can Now Intercept All HTTPS Traffic

mitmproxy capturing iPhone traffic

Understanding the Transparent Proxy Approach

🔍 How It Works
  1. Network-level interception
    Traffic is redirected at the packet filter level, before applications can bypass proxy settings
  2. Transparent operation
    The iPhone doesn't know a proxy exists - it believes it's connecting directly to servers
  3. USB tethering
    Ensures all traffic routes through your Mac, preventing cellular data bypass

Keyboard Shortcuts and Tips

⌨️ Keyboard Shortcuts
In mitmproxy:
?
See all available commands
f
Filter traffic (e.g., ~d facebook.com to show only Facebook traffic)
i
Inspect request/response details
e
Export captured traffic
z
Clear the current view
Alternative Interfaces:
  • Use mitmweb for a web-based UI
  • Use mitmdump for command-line scripting

Troubleshooting Common Issues

No traffic appearing:

  • Verify the certificate is in "Certificate Trust Settings" and fully trusted
  • Confirm the bridge interface is active: `ifconfig bridge100`
  • Check packet filter rules are loaded: `sudo pfctl -s all`
  • Ensure IP forwarding is enabled: `sysctl net.inet.ip.forwarding`

Certificate errors in apps:

  • Some apps use certificate pinning - this requires additional techniques or may not be bypassable
  • Ensure you've enabled "full trust" for the mitmproxy certificate

Connection issues:

  • Disable Internet Sharing and re-enable it
  • Restart mitmproxy
  • Check firewall settings aren't blocking port 8889

Cleanup and Restoration

When finished testing:

  1. Stop mitmproxy (press `q` and confirm)
  2. Disable Internet Sharing in System Preferences
  3. Remove the packet filter rule from `/etc/pf.conf`
  4. Reload the original configuration: `sudo /sbin/pfctl -f /etc/pf.conf`
  5. Optionally, remove the mitmproxy certificate from your iPhone

Abdullah Diaa

Written by Abdullah Diaa

A seasoned Senior Software Engineer and serial tech entrepreneur with over a decade of expertise in architecting scalable systems, optimizing server-side performance, and leading projects.