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>
75 lines
2.3 KiB
Python
75 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Install chkrootkit/rkhunter + daily dylive inject monitor."""
|
|
import sys
|
|
|
|
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=40, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(cmd, timeout=300):
|
|
_, o, e = c.exec_command(cmd, timeout=timeout)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
print(out[-10000:] if len(out) > 10000 else out)
|
|
return out
|
|
|
|
|
|
print("=== install chkrootkit rkhunter ===")
|
|
run(
|
|
"export DEBIAN_FRONTEND=noninteractive; "
|
|
"apt-get install -y -qq chkrootkit rkhunter 2>&1 | tail -25",
|
|
timeout=300,
|
|
)
|
|
|
|
print("=== update rkhunter db + quick check ===")
|
|
run(
|
|
"rkhunter --update 2>&1 | tail -15; "
|
|
"rkhunter --propupd 2>&1 | tail -10; "
|
|
"rkhunter --check --sk --rwo 2>&1 | tee /tmp/rkhunter_check.txt | tail -40",
|
|
timeout=360,
|
|
)
|
|
|
|
print("=== chkrootkit (quiet) ===")
|
|
run("chkrootkit -q 2>&1 | tee /tmp/chkrootkit.txt | tail -40", timeout=300)
|
|
|
|
monitor = r'''#!/bin/bash
|
|
# Daily check for ClickFix / chain-loader inject on dylive
|
|
set -euo pipefail
|
|
LOG=/var/log/dylive-inject-monitor.log
|
|
URL=https://dylive.nomadro.com/login
|
|
BODY=$(curl -fsSL --max-time 25 "$URL" || echo FAIL)
|
|
TS=$(date -Is)
|
|
if echo "$BODY" | grep -qiE 'data:text/javascript;base64|0xE75744C53eC0914fE9bE92847019D3d7122B6b77|data-seed-prebsc|rpc exhausted'; then
|
|
echo "$TS ALERT inject_detected" >>"$LOG"
|
|
# optional: reload caddy to reassert CSP
|
|
systemctl reload caddy || true
|
|
else
|
|
echo "$TS OK len=${#BODY}" >>"$LOG"
|
|
fi
|
|
'''
|
|
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/usr/local/bin/dylive-inject-monitor.sh", "w") as f:
|
|
f.write(monitor)
|
|
sftp.close()
|
|
run(
|
|
"chmod 755 /usr/local/bin/dylive-inject-monitor.sh; "
|
|
"echo '*/30 * * * * root /usr/local/bin/dylive-inject-monitor.sh' > /etc/cron.d/dylive-inject-monitor; "
|
|
"/usr/local/bin/dylive-inject-monitor.sh; "
|
|
"tail -5 /var/log/dylive-inject-monitor.log"
|
|
)
|
|
|
|
print("=== public exposure check (should be local-only for 8014/4015) ===")
|
|
run(
|
|
"ss -lntp | grep -E ':8014|:4015|:22 |:80 |:443 '; "
|
|
"fail2ban-client status sshd | head -15; "
|
|
"systemctl is-active fail2ban unattended-upgrades douyinweb-api douyinweb-web caddy"
|
|
)
|
|
|
|
c.close()
|
|
print("DONE")
|