Files
Claude-BugHunter/eval/oracle_portswigger.py
Sachin SharmaandClaude Opus 4.8 c215b91129 eval(v1): PortSwigger Academy oracle + runner (real skill-delta tier)
Juice Shop is memorized (v0 ceiling effect); PortSwigger lab solutions are far less
so, which is where the skills-on/off delta actually shows. Adds that tier sharing
v0's agent engine + metrics.

- oracle_portswigger.py: GET the live lab instance root, read its self-rendered
  status widget (`widgetcontainer-lab-status is-solved` / `is-notsolved`). Parser
  self-test passes 4/4 (solved / not-solved / double-quoted / no-widget).
- run_eval_ps.py: per (lab x condition) runs the agent vs the instance URL, polls the
  widget oracle. Reuses run_eval.run_agent + build_task (generalized to any target).
- ps_labs.json: HTTP-solvable lab set (SQLi / IDOR / access-control / SSRF / auth).
  Browser-victim XSS/CSRF labs excluded (need exploit-server + simulated-victim loop).

Launch stays manual by design: the Academy launch flow is JS + CSRF gated under
/Academy/ (verified — the guessable /labs/launch/<id> path 404s), and every existing
tool has the human launch in-browser and paste the instance URL. v1.1 idea: a
Playwright headless launcher using a logged-in profile.

Cannot be run here without an Academy session to launch instances; the oracle is
unit-tested, the runner validated, v0 Juice Shop path unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 21:22:11 +05:30

63 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""
PortSwigger Web Security Academy lab solved-status oracle.
A running lab instance (https://<32-hex>.web-security-academy.net/) renders a
status widget into its page chrome:
SOLVED -> <div class='widgetcontainer-lab-status is-solved'> ... <p>Solved</p>
NOT SOLVED -> <div class='widgetcontainer-lab-status is-notsolved'> ... <p>Not solved</p>
So the oracle just GETs the instance root and matches the widget class. (Reference
implementation: canhieu2412/BSCPscan pwnbscp/recon.py _detect_lab_solved.)
python3 eval/oracle_portswigger.py # parser self-test
python3 eval/oracle_portswigger.py https://XXXX.web-security-academy.net # live check
"""
import sys
import urllib.request
def ps_solved(instance_url, timeout=12):
"""Return (solved, ok). solved in {True, False, None}; ok=False means the widget
could not be read (expired instance / wrong URL / network)."""
url = instance_url.rstrip("/") + "/"
try:
req = urllib.request.Request(url, headers={"User-Agent": "claude-bughunter-eval-oracle"})
html = urllib.request.urlopen(req, timeout=timeout).read().decode("utf-8", "replace")
except Exception:
return None, False
return _classify(html)
def _classify(html):
# primary: the widget class is authoritative
if "widgetcontainer-lab-status is-solved" in html:
return True, True
if "widgetcontainer-lab-status is-notsolved" in html:
return False, True
# secondary: bare class / status text (handles minor markup variation)
if "is-notsolved" in html or "Not solved" in html:
return False, True
if "is-solved" in html or ">Solved<" in html:
return True, True
return None, False # widget not present — probably not a live lab instance
def _selftest():
SOLVED = "<div class='widgetcontainer-lab-status is-solved'><span>LAB</span><p>Solved</p></div>"
NOTSOLVED = "<div class='widgetcontainer-lab-status is-notsolved'><span>LAB</span><p>Not solved</p></div>"
DQ_SOLVED = '<div class="widgetcontainer-lab-status is-solved"><p>Solved</p></div>'
NEITHER = "<html><body>some random page</body></html>"
assert _classify(SOLVED) == (True, True), "solved widget"
assert _classify(NOTSOLVED) == (False, True), "not-solved widget"
assert _classify(DQ_SOLVED) == (True, True), "double-quoted solved"
assert _classify(NEITHER) == (None, False), "no widget"
print("oracle_portswigger parser self-test: PASS (4/4)")
if __name__ == "__main__":
_selftest()
if len(sys.argv) > 1:
print(sys.argv[1], "->", ps_solved(sys.argv[1]))