ass5_10
ass5_10
if request.path == "/login":
if request.method == "POST":
account_name = request.form.get("account_name")
secret = request.form.get("secret")
assert account_name, "Missing `account_name` form"
assert secret, "Missing `secret` form"
session["account"] = int(account["rowid"])
return redirect(request.path)
if request.path == "/is-exposed":
account_id = int(session.get("account", -1))
account = db.execute("SELECT * FROM credentials WHERE rowid = ?",
(account_id,)).fetchone()
assert account, "Not logged in"
db.execute(f"UPDATE credentials SET is_exposed = TRUE WHERE rowid = ?",
(account_id,))
return "true\n"
if request.path == "/info":
assert "account" in request.args, "Missing `account` argument"
account_id = int(request.args["account"])
account = db.execute("SELECT * FROM credentials WHERE rowid = ?",
(account_id,)).fetchone()
assert account, "Invalid `account`"
info = [account["account_name"]]
if account["is_exposed"]:
info.append(account["secret"])
return " ".join(info) + "\n"
if request.path == "/visit":
url = request.args.get("url")
assert url, "Missing `url` argument"
url_arg_parsed = urllib.parse.urlparse(url)
assert url_arg_parsed.hostname == capture_url, f"Invalid `url`, hostname
should be `{capture_url}`"
account_form = {
"account_name": "flag",
"secret": flag,
}
for name, value in account_form.items():
field = browser.find_element(By.NAME, name)
field.send_keys(value)
browser.get(url)
time.sleep(1)
return "Visited\n"
if request.path == "/echo":
echo = request.args.get("echo")
assert echo, "Missing `echo` argument"
return html(echo)
The visit path logs into the account for us, and then goes to a URL that we can
specify. We can see that the is-exposed path exposes the secret field for the flag
account (which is the value of the flag). So we can send the visit path to the is-
exposed path, and then go to the info path and get the value of the flag.
Go to firefox on desktop.
`http://capture.local/visit?url=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttp%2Fcapture.local%2Fis-exposed`
`http://capture.local/info`