magicnet-device-debugging
Skill226 starsChanged 13 days agoMITView on GitHub
Debug and verify MagicNet on a real Android root device. Use when working on MagicNet MCP usage, adb/root validation, TUN/eBPF transparent status, DNS leak diagnosis, sing-box behavior, certificate-less packet capture, eCapture/tcpdump checks, support bundles, device logs, or module runtime issues under /data/adb/modules/MagicNet.
- Reads credentials
- Sends data out
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- android-cliSkill
- kamfwSkill
- perfetto-sqlSkill
- perfetto-trace-analysisSkill
- recipe-maintenanceSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 5 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 8
Use the connected Android device as the source of truth.
- Very specific: line 21
Never print or commit secrets from .env, subscriptions, MCP secrets, device tokens, or raw logs containing private traffic.
- Very specific: line 22
Read .env only when a task needs local private defaults.
- Very specific: line 23
Use /sdcard/Download/MagicNet/ for device-side temporary transfer files.
- Very specific: line 24
Use su -M -c on KernelSU devices unless the current device proves another root invocation is required.
- Very specific: line 25
Keep packet capture diagnostic-only.
- Very specific: line 26
Do not reintroduce Android CA injection.
- Very specific: line 27
Do not add module-level post-fs-data.sh or placeholder uninstall.sh just for compatibility.
- Distinctive: line 32
Start with read-only evidence:
- Very specific: line 61
If cli mcp status reports a different port, use that port in adb forward and in any local .mcp.json endpoint.
- Distinctive: line 63
Read the secret into a local shell variable without echoing it:
- Very specific: line 74
If the local MCP client reads .mcp.json, verify it points at http://127.0.0.1:8766/mcp unless cli mcp status reports a different port.
- Very specific: line 78
Use cli transparent status and cli health as the first-line status view.
- Very specific: line 98
Do not accept an AI routing fix from config inspection alone.
- Very specific: line 106
Follow command-line probes with a real browser visit when the user's acceptance criterion is website usability.
- Distinctive: line 107
If testing temporarily changes a selector through the Clash API or WebUI, record its original selection and restore it before finishing.
- Distinctive: line 112
Use these methods when the user wants packet evidence without installing a CA certificate.
- Distinctive: line 134
If the interface is unclear, list candidates:
- Very specific: line 142
Use the bundled eCapture wrapper when cli ecapture status says the binary is installed and executable.
- Very specific: line 164
When auditing stale MagicNet files, treat these paths as removed mainline features:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MagicNet Device Debugging
Use the connected Android device as the source of truth. MagicNet is a root module; local config checks cannot prove vendor networking, KernelSU/Magisk behavior, TUN state, DNS routing, or real packet capture.
Execution Environment
This skill may run in either of two environments:
- Android Termux (the current device): commands execute on the Android device itself. Do not use
adb; inspect/data/adb/modules/MagicNetdirectly and usesu -M -c '...'for root-only operations. - Computer/host shell: commands execute on a separate computer. Use
adb shell/adb pullonly when a connected device is actually needed, and first select the reported device serial.
Determine the environment before collecting evidence: uname -a, getprop ro.build.version.sdk 2>/dev/null, and command -v adb. The presence of adb alone does not mean the shell is a host; Android Termux may have adb installed while still being the device shell. Prefer direct local access when /data/adb/modules/MagicNet exists.
Ground Rules
- Never print or commit secrets from
.env, subscriptions, MCP secrets, device tokens, or raw logs containing private traffic. - Read
.envonly when a task needs local private defaults; do not copy its values into docs, patches, issues, commits, or replies. - Use
/sdcard/Download/MagicNet/for device-side temporary transfer files. Do not use/data/local/tmp. - Use
su -M -con KernelSU devices unless the current device proves another root invocation is required. - Keep packet capture diagnostic-only. Do not restore the removed proxy MITM/TProxy capture path,
cli capture, capture config files, orlib/magicnet/capture_*. - Do not reintroduce Android CA injection.
system/etc/security/cacerts,cli cert, and generated MagicNet local CA support were removed; use tcpdump or eCapture for no-certificate diagnostics. - Do not add module-level
post-fs-data.shor placeholderuninstall.shjust for compatibility. MagicNet usesservice.shandboot-completed.sh; uninstall hooks belong in kamfw only when real cleanup exists. - Current MagicNet mainline explicitly supports sing-box
tun|ebpf, withtunas the default. Do not addautoor restore TProxy, Redirect, or netdALLOW_MULTI; usecli transparent statusandcli health, notcli ebpf status.
Baseline Snapshot
Start with read-only evidence:
adb devices -l
adb shell 'getprop ro.product.model; getprop ro.build.version.release; getprop ro.build.version.sdk'
adb shell 'su -M -c "id"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli service status"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli health"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli transparent status"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli ecapture status || true"'For network work, capture routes and listeners before changing anything:
adb shell 'su -M -c "ip addr; ip route; ip rule"'
adb shell 'su -M -c "ss -lntup 2>/dev/null | grep -E \"sing-box|magicnet|789|909|876\" || true"'MCP Usage
MagicNet exposes a Streamable HTTP MCP server from the device module. Enable it explicitly, read the actual bind/port from cli mcp status, forward that port to localhost, then call it with the device-generated secret.
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli mcp enable 127.0.0.1 8766"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli mcp status"'
adb forward tcp:8766 tcp:8766If cli mcp status reports a different port, use that port in adb forward and in any local .mcp.json endpoint. Do not assume stale docs or client config are correct.
Read the secret into a local shell variable without echoing it:
MCP_SECRET="$(adb shell 'su -M -c "/data/adb/modules/MagicNet/cli mcp secret"' | tr -d '\r')"
curl -fsS -X POST http://127.0.0.1:8766/mcp \
-H "Authorization: Bearer ${MCP_SECRET}" \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
unset MCP_SECRETIf the local MCP client reads .mcp.json, verify it points at http://127.0.0.1:8766/mcp unless cli mcp status reports a different port. If calls fail, inspect /data/adb/modules/MagicNet/.log/mcp-server.log with redaction.
Transparent Dataplane Status
Use cli transparent status and cli health as the first-line status view. Never infer effective mode from magicnet0 alone and never treat the capability probe as attachment proof.
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli transparent status"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli health"'
adb shell 'su -M -c "ip -o link show magicnet0 2>/dev/null || true"'
adb shell 'su -M -c "test -f /sys/fs/cgroup/cgroup.controllers && cat /sys/fs/cgroup/cgroup.controllers || true"'
adb shell 'su -M -c "ip rule; ip route; tc qdisc show 2>/dev/null || true"'Interpret status conservatively:
- Configured/effective
tun, a healthy Dataplane check, and a presentmagicnet0are the expected TUN state. - Configured
ebpfmust not requiremagicnet0. Verify local cgroup backend state; for hybrid, verify that every reported shared interface is an actual current downstream interface and that TC attachment is reported.shared=pendingis valid when no confirmed downstream interface exists. - Capability/probe success means the kernel can load the requested programs; it does not prove the current sing-box process owns active cgroup/TC attachments. Preserve that distinction in reports.
- A mode mismatch, rollback/pending state, missing expected attachment, or health warning can be a startup, routing, kernel, or vendor-network issue; collect surrounding health, process, cgroup, TC, and route evidence before changing anything.
cli ebpf statusremains intentionally unavailable. Do not report its absence as a device fault or add an eBPF/netd fallback path. The internalsing-box tools ebpf statuscommand is a non-destructive capability probe only.
AI Website Routing Acceptance
Do not accept an AI routing fix from config inspection alone. On the installed device, verify all four public websites through MagicNet's local HTTP proxy at 127.0.0.1:7892:
adb shell 'su -M -c '\''for url in https://chatgpt.com/ https://gemini.google.com/ https://grok.com/ https://claude.ai/; do curl -sS -o /dev/null -w "%{http_code} $url\n" --max-time 30 -x http://127.0.0.1:7892 "$url"; done'\'''- Require an HTTP response from every site. A redirect, authentication response, or application response proves reachability; timeout, DNS failure, TLS failure, or proxy failure does not.
- For each request, collect sing-box logs proving traffic selected its dedicated outbound:
ai-chatgpt,ai-gemini,ai-grok, orai-claude. Reject anymissing outbound,outbound not found, or equivalent error. - Follow command-line probes with a real browser visit when the user's acceptance criterion is website usability. Confirm the page loads through MagicNet rather than only proving TCP/TLS reachability.
- If testing temporarily changes a selector through the Clash API or WebUI, record its original selection and restore it before finishing.
- Redact subscription URLs, node credentials, tokens, cookies, authorization headers, and private browsing data from commands, logs, screenshots, and reports.
Certificate-Less Packet Capture
Use these methods when the user wants packet evidence without installing a CA certificate.
Metadata Capture With tcpdump
tcpdump needs no certificate and can prove whether traffic leaves a given interface, port, or DNS path. It does not decrypt HTTPS payloads.
adb shell 'su -M -c "timeout 15 tcpdump -i any -nn -c 40 '\''tcp port 443 or udp port 53 or tcp port 53 or tcp port 853 or udp port 853'\''"'Trigger traffic in parallel from another shell:
adb shell 'am start -a android.intent.action.VIEW -d "https://www.cloudflare.com/cdn-cgi/trace?magicnet_probe=1"'For DNS leak checks, capture on the physical egress interface when known, such as wlan0 or rmnet_data0, and verify no plain DNS/DoT leaves unexpectedly:
adb shell 'su -M -c "timeout 12 tcpdump -ni wlan0 '\''port 53 or port 853'\''"'If the interface is unclear, list candidates:
adb shell 'su -M -c "ip -o link show | cut -d: -f2 | tr -d \" \""'eCapture Packet Or TLS Diagnostics
Use the bundled eCapture wrapper when cli ecapture status says the binary is installed and executable. Treat a successful process exit as "probe started"; verify capture success by checking the output file is non-empty.
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli ecapture status"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli ecapture pcap 15 wlan0 tcp port 443"'
adb shell 'su -M -c "/data/adb/modules/MagicNet/cli ecapture tls 15 all all"'Expected outputs are under /data/adb/modules/MagicNet/.log/, such as ecapture.pcapng, ecapture-pcap.log, ecapture-tls.log, and ecapture-tls-events.log. Confirm file content:
adb shell 'su -M -c "ls -lh /data/adb/modules/MagicNet/.log/ecapture.pcapng; wc -c /data/adb/modules/MagicNet/.log/ecapture.pcapng"'Boundaries:
cli ecapture pcapcan write packet captures, not decrypted application payloads. If the file is 0 bytes, report pcap output as not validated even if probes started.cli ecapture tlscan expose TLS plaintext events without installing a CA, but only when the kernel, eBPF probes, architecture, and target TLS library are compatible.- Browser/app HTTPS plaintext is not guaranteed. If TLS mode is silent, fall back to packet metadata and routing/DNS evidence.
Legacy Cleanup Checks
When auditing stale MagicNet files, treat these paths as removed mainline features:
find /data/adb/modules/MagicNet -maxdepth 4 \( \
-path '*/system/etc/security/cacerts*' \
-o -name 'post-fs-data.sh' \
-o -name 'sepolice.rule' \
-o -name 'capture_common.sh' \
-o -name 'capture_singbox.sh' \
-o -name 'capture.conf' \
\) -printExpected result for a current install is no output. If old files appear on a device, they are migration residue; do not build new behavior around them.
For kamfw uninstall behavior, check the framework, not MagicNet module root:
adb shell 'su -M -c "test -f /data/adb/modules/MagicNet/uninstall.sh && sed -n '\''1,120p'\'' /data/adb/modules/MagicNet/uninstall.sh || true"'An uninstall script is only meaningful if it contains real rollback commands or calls kamfw run uninstall -- "$@".
To pull a capture for local inspection, copy through the approved transfer directory and clean it after use:
adb shell 'mkdir -p /sdcard/Download/MagicNet'
adb shell 'su -M -c "cp /data/adb/modules/MagicNet/.log/ecapture.pcapng /sdcard/Download/MagicNet/ecapture.pcapng"'
adb pull /sdcard/Download/MagicNet/ecapture.pcapng .
adb shell 'rm -f /sdcard/Download/MagicNet/ecapture.pcapng'Reporting
Report only concise evidence:
- Device model, Android version, and root availability.
- MagicNet service, health, configured/effective transparent dataplane, MCP, and capture status.
- Whether tcpdump or eCapture captured packets.
- Whether HTTPS plaintext was expected, observed, or unavailable.
- Any DNS leak evidence by interface and port, without exposing private domains beyond what the user asked to test.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

