Skip to content

Latest commit

 

History

History
236 lines (163 loc) · 8.68 KB

File metadata and controls

236 lines (163 loc) · 8.68 KB
description How to set up capture all HTTPS Request Response from Proxyman with Automatic Script

Automatic Script for Android Emulator

1. What's it?

It's too complicated and error-prone if we manually override the HTTP Proxy, Install, and Trust Proxyman Certificate from your Android Emulator.

Thus, Proxyman provides a built-in script to automatically perform it in a second. You can access it from Certificate Menu -> Install Certificate on Android -> Emulator.

{% hint style="success" %} From Proxyman 5.15.0 or later, Proxyman can now install Proxyman certificate into the system-level Store. Make it possible to decrypt all HTTPS from Android Emulators. {% endhint %}

{% hint style="info" %} Proxyman nows can works with Google-Play and non Google-Play Emulators. 1 click to override. Refer at google-play-android-emulator-with-magisk.md {% endhint %}

capture traffic from Android Emulator - including Flutter app

2. Benefit?

1 Click to:

  • ✅ Auto Override / Revert HTTP Proxy
  • ✅ Automatically download, install, and trust the Proxyman Certificate at the system-level store. Can decrypt all HTTPS from your Emulators. (Available on Proxyman 5.16.0 or later)
  • No need network_security_config.xml
  • ✅ Less error-prone and finishes in a few clicks

{% hint style="success" %} Work with Android Emulator and Android Physical Devices via `adb` (Only for Proxyman v5.19.0+) {% endhint %}

Capture and decrypt HTTPS from Android Emulators with Proxyman

  • Install Proxyman Certificate to the system-level Store.

Install Proxyman Certificate to the system-level Store.

✅ Flutter / React Native app

From Proxyman macOS 6.4.0 or later, Proxyman can capture HTTPS traffic from the Flutter app without a code change required.

Refer flutter.md documentation to know more.

3. How to use it?

  1. Make sure the adb command is installed. If not, please install it
brew install android-platform-tools
  1. Open your Android app with Android Studio
  2. Create a new Emulator in Android Virtual Device Manager. Make sure it's not the Play Store. Must be a Google Play API

Create new Google APIs Android Emulators

Create a new Emulator (Google APIs)

  1. Open Proxyman -> Certificate Menu -> Install Certificate on Android -> Emulators -> Click on the Override All Emulators button

capture all HTTPS from Emulators with 1 click

  1. Wait until the Terminal completes

  1. Relaunch your Android app on Android Studio
  2. Proxyman will capture all HTTPS data ✅

{% hint style="info" %} If you close Proxyman, make sure to click on the Revert All Changes button. Otherwise, your Android Emulator could not access the Internet. {% endhint %}

4. ⚠️ Proxyman 5.15.0 or earlier

  • Proxyman 5.15.0 or earlier is only able to install Proxyman Certificate to the User level.
  • It means: We have to complete the next step:
  • In your source code:
    • Add res/xml/network_security_config.xml
<network-security-config>
    <debug-overrides>
        <trust-anchors>
            <!-- Trust user added CAs while debuggable only -->
            <certificates src="user" />
            <certificates src="system" />
        </trust-anchors>
    </debug-overrides>

    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>
  • Add to AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:networkSecurityConfig="@xml/network_security_config">
        <activity
            ...
        </activity>
    </application>

</manifest>

5. Advance: Run the script manually

It's possible to execute the script manually in your Terminal app without granting the Automation Permission in Security & Privacy.

Script path:

{% code overflow="wrap" %}

/Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh

{% endcode %}

  • For Proxyman 51.9.0 or later

{% code overflow="wrap" %}

Usage: /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh -m <mode> [options]

Modes:
  all             Set proxy and install certificate
  proxy           Set proxy only
  revertProxy     Revert proxy settings only
  certificate     Install certificate only

Required Options based on Mode:
  -m, --mode <mode>              : Operation mode (all, proxy, revertProxy, certificate)
  -i, --ip <ip_address>          : IP address (required for all, proxy, certificate)
  -p, --port <port_number>       : Port number (required for all, proxy, certificate)
  -c, --cert <path_to_cert.pem>  : Path to Proxyman certificate (required for all, certificate)

Optional Options:
  --include-physical            : Include physical devices (default: only emulators)
  -h, --help                    : Show this help message

{% endcode %}

Prepare the certificate

  1. Open the Proxyman app
  2. Find the current IP in the Main Toolbar
  3. Certificate menu -> Export -> Root Certificate as PEM -> Save to Desktop folder

5.1 Override HTTP Proxy and Install the Certificate to system-level Store

  • Proxyman v5.19.0 or later (NEW)

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh --mode all --ip <current_ip> --port <port> --cert <certificate_path>

{% endcode %}

  • Proxyman v5.18.0 or earlier

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh all <current_ip> <port> <certificate_path>

{% endcode %}

5.2 Only Override HTTP Proxy

  • Proxyman v5.19.0 or later (NEW)

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh --mode proxy --ip <current_ip> --port <port>

{% endcode %}

  • Proxyman v5.18.0 or earlier

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh proxy <current_ip> <port> 

{% endcode %}

5.3 Revert HTTP Proxy

  • Proxyman v5.19.0 or later (NEW)

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh --mode revertProxy

{% endcode %}

  • Proxyman v5.18.0 or earlier

{% code overflow="wrap" %}

bash /Applications/Proxyman.app/Contents/Frameworks/ProxymanCore.framework/Resources/install_certificate_android_emulator.sh revertProxy

{% endcode %}

6. Left certificate expiry date

6.1 Problem: If you got this error when intercepting HTTPS from WebView Android

❗️ Android WebView rejects with ERR_CERT_VALIDITY_TOO_LONG

You can change the leaf certificate's expiry at