Files
felhom.eu/documentation/audits/night-2026-09-25/tools/switch.py
T

15 lines
931 B
Python

"""POST /settings/app-update through the product's form (on|off), then read the settings page's box back."""
import sys, re, os
import walk as w
w.login()
on = sys.argv[1] == "on"
sess = open(f"{w.SC}/sess{os.getpid()}.txt").read().strip(); csrf = open(f"{w.SC}/csrf{os.getpid()}.txt").read().strip()
args = ["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", "-H", w.HOSTHDR, "-H", f"Cookie: {sess}", "-X", "POST", "--data-urlencode", f"_csrf={csrf}"]
if on:
args += ["--data-urlencode", "app_update_unattended=on"]
r = w.sh(args + [f"{w.BASE}/settings/app-update"])
h = w.page("/settings")
m = re.search(r'data-app-update-unattended="(\w*)"', h)
print(f"POST /settings/app-update {'on' if on else 'off'} -> {r.stdout}; page reads unattended={m.group(1) if m else None}")
print("settings.json:", w.guest("grep -o '\"app_update\":{[^}]*}' /var/lib/docker/volumes/felhom-controller-data/_data/data/settings.json").strip())