--- # 🌐 **Mitmproxy Usage Guide** * (By Kitano Sakura)* --- ## 🛠️ **Prerequisites** - Download and install [**Mitmproxy**](https://mitmproxy.org/). - Basic knowledge of **WireGuard** and **Python scripting**. - Required devices: - A host machine to run **Mitmproxy**. - A client device (e.g., Android emulator or smartphone). --- ## 📥 **Step 1: Install Mitmproxy** ### 📂 Installation #### Linux / macOS ```bash # Ubuntu/Debian sudo apt update sudo apt install mitmproxy # macOS brew install mitmproxy ``` #### Windows Download the `.exe` installer from [**mitmproxy.org**](https://mitmproxy.org/) and follow the setup instructions. ### ✅ Verify Installation Run the following command to confirm successful installation: ```bash mitmproxy --version ``` --- ## 🔑 **Step 2: Install the CA Certificate** ### 📜 Steps 1. Start `mitmproxy` to generate the CA certificate: ```bash mitmdump ``` 2. Locate the generated certificate: - Certificate path: - `C:\Users\\.mitmproxy\mitmproxy-ca-cert.crt` (Windows) - `~/.mitmproxy/` (Linux / macOS) 3. Rename `mitmproxy-ca-cert.crt` to `c8750f0d.0`. 4. Move the certificate to the system CA directory and set permissions: ```bash adb root adb remount adb shell mv /sdcard/c8750f0d.0 /system/etc/security/cacerts/ adb shell chmod 644 /system/etc/security/cacerts/c8750f0d.0 adb reboot ``` --- ## 🔧 **Step 3: Configure the Redirect Script** Download `redirect_server.py` from the repository and modify the `SERVER_HOST` field: ```python import gzip import json from mitmproxy import http SERVER_HOST = 'Update here' # Replace with your server IP SERVER_PORT = 80 REWRITE_HOST_LIST = [ 'ba-jp-sdk.bluearchive.jp', 'prod-gateway.bluearchiveyostar.com', 'prod-game.bluearchiveyostar.com', ] ``` --- ## 🚀 **Step 4: Start Mitmproxy** Run the following command to launch Mitmproxy with the redirect script: ```bash mitmweb -m wireguard --no-http2 -s redirect_server.py --set termlog_verbosity=warn --ignore ``` ### 📝 Parameter Explanation: - `-m wireguard`: Use WireGuard as the network layer. - `--no-http2`: Disable HTTP/2 for better compatibility. - `-s redirect_server.py`: Load the redirect script. - `--set termlog_verbosity=warn`: Show warnings only in logs. Access the Mitmproxy web interface at `http://localhost:8081` to monitor traffic. --- ## 🔄 **Step 5: Install WireGuard** ### 📥 Installation - **Android**: Download from [**Google Play**](https://play.google.com/store/apps/details?id=com.wireguard.android). - **Other Platforms**: Refer to the [**official WireGuard installation guide**](https://www.wireguard.com/install/). ### ⚙️ Configuration 1. Open the WireGuard client and scan the QR code provided by Mitmproxy. 2. Apply the configuration to route all traffic through Mitmproxy. --- ## 🛠️ **Troubleshooting** ### ❌ Error: Client TLS handshake failed - Ensure the same CA certificate is installed on both the host and client devices. - Verify that the CA certificate is installed as a system certificate. ### ❌ Certificate disappears on Android - Use MT Manager to grant SU permissions. - Manually navigate to `/system/etc/security/cacerts/` and reset permissions to `644`. --- 🎉 **Done!**