# The challenge returns a path containing the upload directory. Keep the # extraction conservative and fail instead of guessing a path. match = re.search(r"(?:/challenge/web-19/)?([0-9a-f]{40})/" + re.escape(filename), response.text) ifnotmatch: raise RuntimeError("upload directory was not found in the response") return urljoin(challenge_url, match.group(0))
defmain() -> None: parser = argparse.ArgumentParser() parser.add_argument("--url", default="https://webhacking.kr/challenge/web-19/") parser.add_argument("--filename", default="123") parser.add_argument("--cookie", help="optional session cookie; do not put it in the article") args = parser.parse_args()
session = requests.Session() if args.cookie: session.cookies.set("session-cookie", args.cookie, domain="webhacking.kr", path="/")