This repository has been archived on 2025-01-22. You can view files and clone it, but cannot push or open issues or pull requests.
SCHALE.GameServer/Mitmproxy_Readme_EN.md

3.5 KiB

# 🌐 Mitmproxy Usage Guide
* (By Kitano Sakura)*

🛠️ Prerequisites

  • Download and install Mitmproxy.
  • 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

# Ubuntu/Debian
sudo apt update
sudo apt install mitmproxy

# macOS
brew install mitmproxy

Windows

Download the .exe installer from mitmproxy.org and follow the setup instructions.

Verify Installation

Run the following command to confirm successful installation:

mitmproxy --version

🔑 Step 2: Install the CA Certificate

📜 Steps

  1. Start mitmproxy to generate the CA certificate:
    mitmdump
    
  2. Locate the generated certificate:
    • Certificate path:
      • C:\Users\<Username>\.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:
    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:

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:

mitmweb -m wireguard --no-http2 -s redirect_server.py --set termlog_verbosity=warn --ignore <your IP address>

📝 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

⚙️ 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!