# -*- coding: utf-8 -*- """Audit + ensure Neko WebRTC ports on US VPS (UFW + listen + external probe).""" from __future__ import annotations import socket import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") HOST = "108.174.50.68" USER = "root" PASS = "Xiao4669805" REMOTE = r""" set -e echo '===== OS / provider hints =====' hostnamectl 2>/dev/null | head -12 || true ip -4 addr show | sed -n '1,40p' echo echo '===== UFW =====' if command -v ufw >/dev/null 2>&1; then ufw status verbose || true echo '--- ensure rules ---' ufw allow 52300:52331/tcp || true ufw allow 52300:52331/udp || true ufw allow 52000:52098/udp || true ufw allow 52101:52199/udp || true ufw allow 52201:52299/udp || true ufw status numbered | head -60 || true else echo 'ufw not installed' fi echo echo '===== iptables INPUT (top) =====' iptables -L INPUT -n -v 2>/dev/null | head -50 || true echo echo '===== nft / firewalld =====' command -v nft >/dev/null && nft list ruleset 2>/dev/null | head -5 || echo 'nft: n/a' command -v firewall-cmd >/dev/null && firewall-cmd --list-all 2>/dev/null | head -40 || echo 'firewalld: n/a' echo echo '===== listening WebRTC =====' ss -ulnp 2>/dev/null | grep -E '5200|5210|5220|5230' | head -40 || true ss -tlnp 2>/dev/null | grep -E '5230' | head -20 || true echo echo '===== docker neko =====' docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Ports}}' | grep -i neko | head -20 || true echo echo '===== cloud-init / vendor =====' ls /etc/cloud 2>/dev/null | head || true cat /var/lib/cloud/instance/datasource 2>/dev/null || true dmidecode -s system-manufacturer 2>/dev/null || true dmidecode -s system-product-name 2>/dev/null || true curl -s --max-time 3 http://169.254.169.254/latest/meta-data/ 2>/dev/null | head || echo 'aws-meta: n/a' curl -s --max-time 3 -H 'Metadata-Flavor: Google' http://169.254.169.254/computeMetadata/v1/instance/ 2>/dev/null | head || echo 'gcp-meta: n/a' curl -s --max-time 3 -H Metadata:true 'http://169.254.169.254/metadata/instance?api-version=2021-02-01' 2>/dev/null | head -c 200 || echo 'azure-meta: n/a' curl -s --max-time 3 http://169.254.169.254/openstack/latest/meta_data.json 2>/dev/null | head -c 200 || echo 'openstack-meta: n/a' """ def tcp_probe(host: str, port: int, timeout: float = 3.0) -> str: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(timeout) try: s.connect((host, port)) return "open" except Exception as ex: return f"fail:{type(ex).__name__}:{ex}" finally: s.close() def udp_probe(host: str, port: int, timeout: float = 2.0) -> str: """Best-effort: send datagram; no reply expected for WebRTC mux usually.""" s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(timeout) try: s.sendto(b"\x00", (host, port)) try: s.recvfrom(64) return "reply" except socket.timeout: return "sent_no_reply" except Exception as ex: return f"fail:{type(ex).__name__}:{ex}" finally: s.close() def main() -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, 22, USER, PASS, timeout=45, allow_agent=False, look_for_keys=False) _i, o, e = c.exec_command(REMOTE, timeout=120) print(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err.strip(): print("STDERR:", err[:2000]) c.close() print("===== external TCP probes from this machine =====") for p in (22, 80, 443, 52300, 52301, 9200, 9201): print(f" TCP {HOST}:{p} -> {tcp_probe(HOST, p)}") print("===== external UDP probes (send-only) =====") for p in (52300, 52301, 52000, 52101): print(f" UDP {HOST}:{p} -> {udp_probe(HOST, p)}") if __name__ == "__main__": main()