Skip to content

TeguFy/android-proxy-manager

Repository files navigation

Android Proxy Manager Logo

Android Proxy Manager

System-wide & per-app proxy management for rooted Android

License: MIT Android Magisk LSPosed API

Route any app through any proxy — HTTP, SOCKS, transparent TPROXY — without touching app code.


✨ Features

Feature Method Layer
🌐 System-wide HTTP proxy Settings.Global.HTTP_PROXY Magisk (root)
🔀 Transparent proxy (all TCP) iptables TPROXY Magisk (root)
📱 Per-app proxy (iptables) iptables -m owner --uid-owner Magisk (root)
🪝 Per-app proxy (hook) OkHttp / ProxySelector hooks LSPosed
🗄️ Proxy profile management Room DB App
🧪 Proxy connectivity test OkHttp direct test App
⚡ CLI / Intent API BroadcastReceiver App
🔁 Auto-restore on boot BootReceiver + Foreground Service App

🔧 Proxy Modes

SYSTEM   →  Settings.Global.HTTP_PROXY     (HTTP/HTTPS, most apps)
TPROXY   →  iptables PREROUTING TPROXY     (all TCP, transparent)
PER_APP  →  iptables OUTPUT MARK per UID   (selected apps only)
         +  LSPosed hooks (OkHttp, ProxySelector, WebView)

🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                     Android App (APK)                        │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │  Compose UI  │  │  ViewModel   │  │  Room Database   │  │
│  │  - HomeScreen│  │  ProxyVM     │  │  - proxies       │  │
│  │  - AddProxy  │  │              │  │  - app_proxies   │  │
│  │  - AppProxy  │  │              │  │                  │  │
│  │  - Settings  │  │              │  │                  │  │
│  └──────────────┘  └──────────────┘  └──────────────────┘  │
│                                                              │
│  ┌──────────────────────────────────────────────────────┐   │
│  │              Intent/CLI API (BroadcastReceiver)       │   │
│  │  SET_GLOBAL_PROXY | CLEAR_GLOBAL | SET_APP_PROXY ...  │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
         │ su                              │ config.json
         ▼                                 ▼
┌─────────────────────┐    ┌──────────────────────────────────┐
│   Magisk Module     │    │         LSPosed Module            │
│                     │    │                                   │
│  service.sh (root)  │    │  XposedInit.kt                   │
│  - iptables TPROXY  │    │  - Hook ProxySelector            │
│  - Settings.Global  │    │  - Hook OkHttp3                  │
│  - Named pipe IPC   │    │  - Hook WebView                  │
│                     │    │  - Per-app config from JSON      │
└─────────────────────┘    └──────────────────────────────────┘
         │
         ▼
┌─────────────────────┐
│  /data/local/       │
│  proxy-manager/     │
│  ├── config.json    │  ← shared config (app ↔ magisk ↔ lsposed)
│  ├── cmd.pipe       │  ← named pipe for IPC
│  └── service.pid    │
└─────────────────────┘

📦 Installation

Prerequisites

  • Rooted Android 8.0+ with Magisk 20.4+
  • LSPosed installed (for per-app hook mode)
  • ADB or Android Studio for sideloading

1. Flash Magisk Module

cd magisk-module
zip -r proxy-manager-magisk.zip .
# Flash via Magisk Manager → Modules → Install from storage

2. Install App (includes LSPosed module)

cd app
./gradlew assembleDebug
adb install app/build/outputs/apk/debug/app-debug.apk

3. Enable LSPosed Module

  1. Open LSPosed Manager
  2. Enable Proxy Manager module
  3. Select target apps in scope
  4. Reboot or force-stop target apps

⚡ CLI / Intent API

Control the proxy from ADB or any automation tool:

# Set global proxy — HTTP mode
adb shell am broadcast -a com.proxymanager.SET_GLOBAL_PROXY \
    --es host "1.2.3.4" --ei port 8080 --es mode "SYSTEM"

# Set global proxy — transparent TPROXY mode
adb shell am broadcast -a com.proxymanager.SET_GLOBAL_PROXY \
    --es host "1.2.3.4" --ei port 8080 --es mode "TPROXY"

# Clear global proxy
adb shell am broadcast -a com.proxymanager.CLEAR_GLOBAL_PROXY

# Set per-app proxy (proxy_id from DB)
adb shell am broadcast -a com.proxymanager.SET_APP_PROXY \
    --es package "com.example.app" --el proxy_id 1

# Clear per-app proxy
adb shell am broadcast -a com.proxymanager.CLEAR_APP_PROXY \
    --es package "com.example.app"

# Toggle proxy on/off
adb shell am broadcast -a com.proxymanager.TOGGLE_PROXY

# Reload config (after manual config.json edit)
adb shell am broadcast -a com.proxymanager.RELOAD_CONFIG

🗂️ Config File

Shared config at /data/local/proxy-manager/config.json:

{
  "enabled": true,
  "mode": "tproxy",
  "global_proxy": "1.2.3.4:8080",
  "tproxy_port": 8118,
  "app_proxies": {
    "com.example.app": {
      "host": "1.2.3.4",
      "port": 8080,
      "type": "HTTP",
      "uid": 10123,
      "enabled": true
    }
  }
}

📁 Project Structure

android-proxy-rooted/
├── magisk-module/              # Magisk module (flash as zip)
│   ├── module.prop
│   ├── customize.sh            # Installer
│   ├── post-fs-data.sh         # Early boot setup
│   ├── service.sh              # Root service (iptables + IPC)
│   └── META-INF/
│
└── app/                        # Android Studio project
    └── app/src/main/
        ├── AndroidManifest.xml
        ├── assets/xposed_init  # LSPosed entry point
        └── java/com/proxymanager/
            ├── data/           # Room DB, Repository, DataStore
            ├── root/           # RootCommand, IptablesManager, ProxyTester
            ├── service/        # ProxyService, IntentReceiver, BootReceiver
            ├── ui/             # Compose screens
            ├── viewmodel/      # ProxyViewModel
            ├── xposed/         # LSPosed hooks (XposedInit)
            └── di/             # Hilt modules

🔒 Security Notes

  • com.proxymanager.CONTROL permission is signature|privileged — only same-signed or system apps can send control intents
  • ADB shell (adb shell) bypasses this for testing/automation
  • Config at /data/local/proxy-manager/ must be readable by LSPosed hooks running in other app processes
  • See SECURITY.md for vulnerability reporting

🤝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md before submitting a PR.

📄 License

MIT © 2026 Android Proxy Manager Contributors

About

**System-wide & per-app proxy management for rooted Android**

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors