#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") CMD = r""" echo 4669805 | sudo -S -p '' bash -lc ' for i in 1 2; do echo "===== OPS$i =====" docker ps -a --filter name=douyinweb-ops-neko-$i --format "{{.Names}} {{.Status}}" docker exec douyinweb-ops-neko-$i bash -lc " echo --- chrome --- supervisorctl status google-chrome 2>/dev/null || true echo --- provisioning --- curl -fsS -m 3 http://127.0.0.1:18080/tampermonkey-provisioning.json | head -c 220; echo echo --- policies --- ls -la /etc/opt/chrome/policies/managed/ 2>/dev/null || ls -la /etc/chromium/policies/managed/ 2>/dev/null || echo NO_POLICIES echo --- env --- env | grep -E \"TAMPER|MANAGED|NEKO_\" | sort echo --- profile --- P=\$(ls -d /home/*/.config/google-chrome/Default 2>/dev/null | head -1) echo PROFILE=\$P if [ -n \"\$P\" ]; then ls \"\$P/Extensions/dhdgffkkebhmkfjojejmpbldmpobfkfo\" 2>/dev/null || echo NO_TM_EXT strings \"\$P/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo\"/* 2>/dev/null | grep -E \"YouTube Studio Auto Dismiss|auto-dismiss\" | head -5 || echo NO_SCRIPT_IN_LES python3 -c \" import json from pathlib import Path p=Path(r\\\"\$P/Preferences\\\") d=json.loads(p.read_text()) if p.exists() else {} e=(d.get(\\\"extensions\\\") or {}).get(\\\"settings\\\") or {} tm=e.get(\\\"dhdgffkkebhmkfjojejmpbldmpobfkfo\\\") or {} print(\\\"tm_state\\\", tm.get(\\\"state\\\"), \\\"path\\\", tm.get(\\\"path\\\"), \\\"disabled\\\", tm.get(\\\"disable_reasons\\\")) \" 2>/dev/null || true fi " 2>&1 | head -100 done echo ===== HOST ASSETS ===== ls -la /opt/douyinWEB/backend/neko/provisioning/ | head grep -n hash /opt/douyinWEB/backend/neko/policies/policies.json | head cd /opt/douyinWEB/backend/neko && python3 render_tampermonkey_provisioning.py 2>&1 | tail -5 ' """ def main() -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False) _i, o, e = c.exec_command(CMD, timeout=120) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() if __name__ == "__main__": main()