95 lines
3.3 KiB
Python
95 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Diagnose ShellCrash /ui on dy.nomadro.com. Live flush."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import httpx
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
|
|
|
|
HOST = "107.173.30.245"
|
|
|
|
|
|
def connect(port=22, user="root", pw="Xiao4669805"):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, port, user, pw, timeout=25, banner_timeout=40, allow_agent=False, look_for_keys=False)
|
|
print(f"connected :{port}", flush=True)
|
|
return c
|
|
|
|
|
|
def run(c, cmd, t=60):
|
|
print(f"$ {cmd[:220]}", flush=True)
|
|
_i, o, e = c.exec_command(cmd, timeout=t)
|
|
while not o.channel.exit_status_ready():
|
|
if o.channel.recv_ready():
|
|
sys.stdout.write(o.channel.recv(4096).decode("utf-8", "replace"))
|
|
sys.stdout.flush()
|
|
if o.channel.recv_stderr_ready():
|
|
sys.stdout.write(o.channel.recv_stderr(4096).decode("utf-8", "replace"))
|
|
sys.stdout.flush()
|
|
time.sleep(0.1)
|
|
sys.stdout.write((o.read() + e.read()).decode("utf-8", "replace"))
|
|
sys.stdout.flush()
|
|
print("->", o.channel.recv_exit_status(), flush=True)
|
|
|
|
|
|
print("## public /ui", flush=True)
|
|
with httpx.Client(follow_redirects=False, timeout=20) as cl:
|
|
for u in [
|
|
"https://dy.nomadro.com/ui/",
|
|
"https://dy.nomadro.com/ui",
|
|
"https://dy.nomadro.com/ui/#/setup",
|
|
"https://dy.nomadro.cn/ui/",
|
|
]:
|
|
try:
|
|
r = cl.get(u)
|
|
print(f"{u} -> {r.status_code} ctype={r.headers.get('content-type','')[:40]} "
|
|
f"loc={r.headers.get('location','')[:60]} body={r.text[:80]!r}", flush=True)
|
|
except Exception as ex:
|
|
print(f"{u} ERR {ex}", flush=True)
|
|
|
|
print("## caddy /ui rules", flush=True)
|
|
v = connect(22)
|
|
run(
|
|
v,
|
|
"grep -nE 'ui|9999|9090|zash|shellcrash|yacd|metacubex' /etc/caddy/sites/dy.nomadro.com.caddy | head -40; "
|
|
"echo ---; "
|
|
"grep -nE 'reverse_proxy 10\\.8\\.0\\.2|reverse_proxy 127\\.0\\.0\\.1' /etc/caddy/sites/dy.nomadro.com.caddy | "
|
|
"grep -E '9999|9090|ui|4015|8014' | head -30",
|
|
)
|
|
v.close()
|
|
|
|
print("## guest shellcrash listen", flush=True)
|
|
g = connect(4014, "eric", "4669805")
|
|
run(
|
|
g,
|
|
"echo 4669805 | sudo -S -p '' bash -lc '"
|
|
"ss -lntp | grep -E \":(9999|9090|9091|7888|8080|6170)\\b\" || true; "
|
|
"ps aux | grep -iE \"[s]hellcrash|[m]ihomo|[c]lash|sing-box|zash\" | head -15; "
|
|
"curl -sS -m 5 -o /dev/null -w local9999=%{http_code}\\\\n http://127.0.0.1:9999/; "
|
|
"curl -sS -m 5 -o /dev/null -w local9999ui=%{http_code}\\\\n http://127.0.0.1:9999/ui/; "
|
|
"curl -sS -m 5 -o /dev/null -w local9090=%{http_code}\\\\n http://127.0.0.1:9090/; "
|
|
"ls /etc/ShellCrash /root/ShellCrash /opt/ShellCrash 2>/dev/null; "
|
|
"systemctl list-units --type=service --all | grep -iE \"shell|clash|mihomo|sing\" | head -20"
|
|
"'",
|
|
t=50,
|
|
)
|
|
g.close()
|
|
|
|
print("## vps frp-aux listens related", flush=True)
|
|
v = connect(22)
|
|
run(
|
|
v,
|
|
"ss -lntp | grep -E ':(9999|9090|18014|14015)\\b' || true; "
|
|
"systemctl cat dy-frp-http-aux.service | head -40; "
|
|
"curl -sS -m 5 -o /dev/null -w vps9999=%{http_code}\\\\n http://127.0.0.1:9999/ui/ || true; "
|
|
"curl -sS -m 5 -o /dev/null -w via_wg9999=%{http_code}\\\\n http://10.8.0.2:9999/ui/ || true",
|
|
t=30,
|
|
)
|
|
v.close()
|
|
print("DONE", flush=True)
|