33 lines
1.7 KiB
Python
33 lines
1.7 KiB
Python
"""rigw.py — the box walk (catalog-sweep-2026-10-24/tools/box_walk.py) pointed at the night's rig: nested VM 9372 on
|
|
demo-hp (Proxmox host 192.168.0.150, BYO install, customer Tester4), guest 9201 at 192.168.0.138, domain tester4.test.
|
|
Import this instead of box_walk; it sets the target before box_walk reads it, then points the ssh at the rig host."""
|
|
import os, sys
|
|
os.environ.setdefault("TARGET", "sweep")
|
|
os.environ.setdefault("BASE", "https://192.168.0.138")
|
|
os.environ.setdefault("DOMAIN", "tester4.test")
|
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../catalog-sweep-2026-10-24/tools"))
|
|
import box_walk as w # noqa: E402
|
|
w._T["ssh"] = "root@192.168.0.150"
|
|
w._T["hp"] = "rig-9372"
|
|
|
|
|
|
def _login():
|
|
"""box_walk.login, but the token is read from /settings: on this fresh box „/" redirects to /launcher, which
|
|
carries no csrf meta (measured 2026-10-25)."""
|
|
import re
|
|
pw = open(f"{w.SC}/.ctlpw").read().strip()
|
|
w.sh(["curl", "-sk", "-D", f"{w.SC}/hdr{os.getpid()}.txt", "-o", "/dev/null", "-H", w.HOSTHDR,
|
|
"-X", "POST", "--data-urlencode", f"password={pw}", f"{w.BASE}/login"])
|
|
m = re.search(r"felhom_session=[A-Za-z0-9._-]+", open(f"{w.SC}/hdr{os.getpid()}.txt").read(), re.I)
|
|
if not m:
|
|
sys.exit("login failed: no session cookie")
|
|
open(f"{w.SC}/sess{os.getpid()}.txt", "w").write(m.group(0))
|
|
r = w.sh(["curl", "-sk", "-H", w.HOSTHDR, "-H", f"Cookie: {m.group(0)}", f"{w.BASE}/settings"])
|
|
c = re.search(r'<meta name="csrf-token" content="([^"]+)"', r.stdout or "")
|
|
if not c:
|
|
sys.exit("login failed: no csrf token on /settings")
|
|
open(f"{w.SC}/csrf{os.getpid()}.txt", "w").write(c.group(1))
|
|
|
|
|
|
w.login = _login
|