89 lines
3.1 KiB
Python
89 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
SCRIPT = r"""#!/bin/bash
|
|
set +e
|
|
N=douyinweb-neko-3
|
|
EXT=dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
echo === chrome ===
|
|
docker exec "$N" supervisorctl status google-chrome
|
|
echo === cmdline ===
|
|
docker exec "$N" bash -lc 'ps -ef | grep -E "[g]oogle-chrome --" | head -3'
|
|
echo === load-extension from /proc ===
|
|
docker exec "$N" bash -lc 'for p in /proc/[0-9]*; do
|
|
[ -r "$p/cmdline" ] || continue
|
|
tr "\0" "\n" < "$p/cmdline" 2>/dev/null | grep -qx google-chrome || continue
|
|
echo PID ${p#/proc/}
|
|
tr "\0" "\n" < "$p/cmdline" | grep -E "load-extension|user-data-dir|disable-extensions" || echo "(no load-extension flags)"
|
|
break
|
|
done'
|
|
echo === prefs+files ===
|
|
docker exec "$N" python3 - <<'PY'
|
|
import json
|
|
from pathlib import Path
|
|
ext="dhdgffkkebhmkfjojejmpbldmpobfkfo"
|
|
base=Path("/home/neko/.config/google-chrome/Default")
|
|
pref=base/"Preferences"
|
|
print("prefs_exists", pref.exists(), "size", pref.stat().st_size if pref.exists() else 0)
|
|
d=json.loads(pref.read_text())
|
|
e=((d.get("extensions") or {}).get("settings") or {}).get(ext) or {}
|
|
print("tm_state", e.get("state"), "location", e.get("location"), "path", e.get("path"))
|
|
print("tm_disable", e.get("disable_reasons"))
|
|
print("ext_manifest", (base/"Extensions"/ext/"5.5.0_0"/"manifest.json").exists())
|
|
print("seed_manifest", Path("/etc/neko/tampermonkey-seed/Default/Extensions/"+ext+"/5.5.0_0/manifest.json").exists())
|
|
print("live_ops", Path("/etc/neko/live-ops-extension/manifest.json").exists())
|
|
print("ext_ids", list(((d.get("extensions") or {}).get("settings") or {}).keys())[:12])
|
|
PY
|
|
echo === CDP ===
|
|
docker exec "$N" python3 - <<'PY'
|
|
import json, urllib.request
|
|
tabs=json.loads(urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=5).read())
|
|
print("tabs", len(tabs))
|
|
for t in tabs:
|
|
u=t.get("url") or ""
|
|
ty=t.get("type") or ""
|
|
if "extension" in u or "dhdgff" in u or ty=="service_worker" or "chrome-extension" in u:
|
|
print(ty, (t.get("title") or "")[:50], u[:160])
|
|
PY
|
|
echo === policies ===
|
|
docker exec "$N" bash -lc 'ls -la /etc/opt/chrome/policies/managed/ 2>/dev/null; head -c 2000 /etc/opt/chrome/policies/managed/*.json 2>/dev/null; echo'
|
|
echo === chrome stderr / openbox last ===
|
|
docker exec "$N" bash -lc 'ls -lt /var/log/supervisor/ 2>/dev/null | head -10; tail -n 40 /var/log/supervisor/google-chrome*.log 2>/dev/null | tail -40'
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
"4669805",
|
|
timeout=45,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=120,
|
|
)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_diag_neko3_tm.sh", "w") as f:
|
|
f.write(SCRIPT)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command(
|
|
"echo '4669805' | sudo -S -p '' bash /tmp/_diag_neko3_tm.sh",
|
|
timeout=90,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|