Files
felhom.eu/documentation/audits/morning-after-2026-10-06/live-9202/tools/nc2.py
T

22 lines
1.5 KiB
Python

import sys, time
sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts")
import box_walk as w
EVF = open(f"{w.EV}/nextcloud.txt", "a", buffering=1)
def say(*a):
w.say(*a); EVF.write(" ".join(map(str, a)) + "\n")
H = "cloud.enkisfelhom.hu"
def tun(v, f, m, p, x=""):
q = lambda s: "'" + s.replace("'", "'\\''") + "'"
return w.guest(f"docker run --rm --network felhom-tunnel --ip 172.16.253.2 -v /root/tun.sh:/t.sh:ro curlimages/curl:8.11.1 "
f"sh /t.sh {H} {v} {f} {m} {q(p)} '' '' {q(x)}").strip().splitlines()[-1:]
occ = lambda a: w.guest(f"docker exec -u www-data nextcloud php occ {a} 2>&1 | tr '\\n' ' '").strip()
say(f"## CONTROL — trusted_proxies removed by hand (the template before R-776) — {time.strftime('%FT%TZ', time.gmtime())}")
say("delete:", occ("config:system:delete trusted_proxies"), "| now:", occ("config:system:get trusted_proxies"))
V2 = "198.51.100.77"
say(f"stranger {V2}, 3 wrong tries:", [tun(V2, f"10.6.0.{i}", "PROPFIND", "/remote.php/dav/files/nobody/", "Authorization: Basic bm9ib2R5Ondyb25n") for i in range(1, 4)])
time.sleep(3)
say(f"attempts {V2} (visitor):", occ(f"security:bruteforce:attempts {V2}"))
for ip in w.guest("docker inspect traefik --format '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}'").split():
say(f"attempts {ip} (traefik):", occ(f"security:bruteforce:attempts {ip}"))
say("restore:", occ("config:system:set trusted_proxies 0 --value=172.16.0.0/12"), "| now:", occ("config:system:get trusted_proxies"))