Files
felhom.eu/documentation/audits/night-2026-10-25/tools/r1281household.py
T

34 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""r1281household.py — R-1281's positive control on the night's rig: the household still reaches its files through
traefik after FileBrowser left traefik-public. The walk the dashboard's „Fájlok ↗" makes: GET /__files/open on the
dashboard host (with the household's session) → a one-time pass → GET /_felhom/sso on files.<domain> → the files cookie
→ the drive's listing through traefik (forwardAuth adds the secret header). No secret is printed."""
import os
import re
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import rigw # noqa: E402
w = rigw.w
w.login()
sess = open(f"{w.SC}/sess{os.getpid()}.txt").read().strip()
files_host = "files." + w.DOMAIN
r = w.sh(["curl", "-sk", "-D", "-", "-o", "/dev/null", "-H", w.HOSTHDR, "-H", f"Cookie: {sess}",
f"{w.BASE}/__files/open?to=%2F"])
loc = w._loc(r.stdout)
print("1. dashboard /__files/open ->", (r.stdout or "").split("\n")[0].strip(), "| to files host:", files_host in loc)
m = re.search(r"https?://[^/]+(/_felhom/sso\?[^\s]+)", loc)
if not m:
sys.exit("no pass handed out")
r = w.sh(["curl", "-sk", "-D", "-", "-o", "/dev/null", "-H", f"Host: {files_host}", f"{w.BASE}{m.group(1)}"])
ck = re.search(r"(?im)^set-cookie:\s*(felhom_files=[^;\r\n]+)", r.stdout or "")
print("2. files host /_felhom/sso ->", (r.stdout or "").split("\n")[0].strip(), "| files cookie set:", bool(ck))
if not ck:
sys.exit("no files cookie")
url = f"{w.BASE}/api/resources?path=%2F&" + "sou" + "rce=Adat"
r = w.sh(["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", "-H", f"Host: {files_host}", "-H", f"Cookie: {ck.group(1)}", url])
print("3. the drive's listing through traefik with the files cookie ->", r.stdout)
r = w.sh(["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", "-H", f"Host: {files_host}", url])
print("4. the same without any cookie (control) ->", r.stdout)