From ca116630bd3a93d9e08cd6bdea33d976dff2a5e3 Mon Sep 17 00:00:00 2001 From: yibo Date: Wed, 24 Jun 2026 14:31:41 +0800 Subject: [PATCH] feat(phoneuse): 把 mitm_proxy 接进 start_all.sh / stop_all.sh --- phoneuse/start_all.sh | 12 ++++++++++++ phoneuse/stop_all.sh | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/phoneuse/start_all.sh b/phoneuse/start_all.sh index 68a5e6f..bfbe272 100644 --- a/phoneuse/start_all.sh +++ b/phoneuse/start_all.sh @@ -13,6 +13,7 @@ export HOME="$TERMUX_HOME" BASE="$HOME/.hermes/event_bus" VENV="$HOME/.hermes/hermes-agent/venv/bin" +PY3="/data/data/com.termux/files/usr/bin/python3" LOGS="$HOME/.hermes/logs" mkdir -p "$LOGS" @@ -84,6 +85,17 @@ except: sleep 1 done +# ── mitm proxy ───────────────────────────────────────────────────────────────── +# Pure-Python HTTPS-intercepting proxy used to capture WeChat traffic. Runs as +# root because ~/.hermes/mitm_ca (the CA + per-host certs) is root-owned from +# earlier setup, and the device's global HTTP proxy (Settings.Global.http_proxy) +# routes every app's HTTPS through MITM_PORT — not just WeChat's. + +start_service "MitmProxy" \ + "$BASE/mitm_proxy.pid" \ + "$LOGS/mitm_proxy.log" \ + su -c "env HOME=$TERMUX_HOME MITM_PORT=8082 $PY3 $BASE/mitm_proxy.py" + # ── APK AgentRuntimeService ──────────────────────────────────────────────────── # The APK provides real-time NotificationListenerService + AccessibilityService # events via EventServerRelay. Start it via root am if not already running. diff --git a/phoneuse/stop_all.sh b/phoneuse/stop_all.sh index 97b1b8a..db47dc6 100644 --- a/phoneuse/stop_all.sh +++ b/phoneuse/stop_all.sh @@ -7,11 +7,14 @@ BASE="$HOME/.hermes/event_bus" stop_service() { local name="$1" local pid_file="$2" + local as_root="$3" if [ -f "$pid_file" ]; then local pid pid=$(cat "$pid_file") - if kill -0 "$pid" 2>/dev/null; then - kill "$pid" && echo "[-] $name stopped (pid $pid)" + local probe="kill -0 $pid" kill_cmd="kill $pid" + [ "$as_root" = "root" ] && probe="su -c '$probe'" && kill_cmd="su -c '$kill_cmd'" + if eval "$probe" 2>/dev/null; then + eval "$kill_cmd" && echo "[-] $name stopped (pid $pid)" else echo "[-] $name not running" fi @@ -23,4 +26,5 @@ stop_service() { stop_service "EventServer" "$BASE/event_server.pid" stop_service "NotificationMonitor" "$BASE/notification_monitor.pid" +stop_service "MitmProxy" "$BASE/mitm_proxy.pid" root echo "Done." -- libgit2 0.21.4