53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
PHYS = ("107.173.30.245", 4014, "eric", "4669805")
|
|
VPS = ("107.173.30.245", 22, "root", "Xiao4669805")
|
|
|
|
SQL = r'''
|
|
python3 - <<'PY'
|
|
import sqlite3, json
|
|
c=sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
keys=c.execute("SELECT key FROM kv_settings ORDER BY 1").fetchall()
|
|
interesting=[k[0] for k in keys if any(x in k[0].lower() for x in ("cookie","oauth","token","proxy"))]
|
|
print("interesting_keys", interesting)
|
|
for k in interesting:
|
|
v=c.execute("SELECT value FROM kv_settings WHERE key=?",(k,)).fetchone()[0]
|
|
try:
|
|
parsed=json.loads(v)
|
|
if isinstance(parsed,str):
|
|
print(k, "str_len", len(parsed))
|
|
elif isinstance(parsed,list):
|
|
print(k, "list_len", len(parsed))
|
|
elif isinstance(parsed,dict):
|
|
print(k, "dict_keys", list(parsed.keys())[:12])
|
|
else:
|
|
print(k, type(parsed).__name__, str(parsed)[:80])
|
|
except Exception:
|
|
print(k, "raw_len", len(v or ""))
|
|
# rooms / shorts sample
|
|
print("rooms", c.execute("select count(*) from rooms").fetchone()[0])
|
|
print("shorts", [(r[0], r[1], bool(r[2]), len(r[3] or "")) for r in c.execute("select id,name,oauth_ok,refresh_token from shorts_channels limit 5")])
|
|
print("assign", [(r[0], r[1], len(r[2] or ""), r[3]) for r in c.execute("select id,name,stream_key,neko_enabled from yt_assign_groups")])
|
|
c.close()
|
|
PY
|
|
'''
|
|
|
|
|
|
def run(spec, cmd):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(*spec, timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False)
|
|
_i, o, e = c.exec_command(cmd, timeout=60)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
print("=== PHYSICAL ===")
|
|
run(PHYS, f"echo '4669805' | sudo -S -p '' bash -lc {repr(SQL)}")
|
|
print("=== DYLIVE ===")
|
|
run(VPS, SQL)
|