Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Check server for malware injection in nginx / next build / umami."""
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(cmd, timeout=120):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
print(out[-5000:] if len(out) > 5000 else out)
|
|
return out
|
|
|
|
|
|
print("=== curl local html snippet ===")
|
|
run(
|
|
"curl -sS http://127.0.0.1:4015/ | tr '\\n' ' ' | grep -oE '.{0,80}data:text/javascript;base64.{0,80}|.{0,80}umami.{0,80}|script src=[^>]{0,120}' | head -40"
|
|
)
|
|
|
|
print("=== search next build for base64 inject ===")
|
|
run(
|
|
"grep -R --include='*.html' --include='*.js' -l 'data:text/javascript;base64' /opt/douyinWEB/frontend/.next 2>/dev/null | head -20; "
|
|
"grep -R --include='*.html' -n 'data:text/javascript;base64' /opt/douyinWEB/frontend/.next/server 2>/dev/null | head -10"
|
|
)
|
|
|
|
print("=== nginx sites ===")
|
|
run("ls /etc/nginx/sites-enabled /etc/nginx/conf.d 2>/dev/null; grep -RIn --include='*.conf' -E 'sub_filter|add_header|lua|inject|recaptcha|base64' /etc/nginx/ 2>/dev/null | head -40")
|
|
|
|
print("=== umami script first bytes ===")
|
|
run("curl -sS https://umami.nomadro.com/script.js | head -c 400; echo; curl -sS https://umami.nomadro.com/script.js | wc -c")
|
|
|
|
print("=== layout on server ===")
|
|
run("grep -n 'script\\|umami\\|base64' /opt/douyinWEB/frontend/src/app/layout.tsx | head -30")
|
|
|
|
c.close()
|
|
print("DONE")
|