Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5067_Labs/Requests/RequestsTrainer/sessionChals.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
78 lines (53 sloc)
1.99 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Challenge For Basic Auth | |
import logging | |
import base64 | |
import flask | |
from .meta import app | |
from .meta import bauth | |
@bauth.verify_token | |
def verify_token(token): | |
if token == "EJUBeTGBlI": | |
return True | |
@app.route("/sessions/challenges/basicAuth") | |
def basicAuth_Challenge(): | |
msg = None | |
logging.warning(flask.request.headers) | |
authToken = flask.request.headers.get("Authorization") | |
logging.warning("Auth Token %s", authToken) | |
#Work out the Hash | |
hashStr = b"Lorgar:Cadia" | |
if authToken: | |
b64Str = base64.b64encode(hashStr) | |
logging.warning("Encoded\t\t %s", b64Str) | |
if not "Basic" in authToken: | |
msg = "Incorrect Basic Auth Format" | |
else: | |
authStr = authToken.strip("Basic").strip().encode() | |
logging.warning("Auth str\t>%s<", authStr) | |
if authStr == b64Str: | |
logging.warning("Correct Creds") | |
msg = "Have a Flag 5067{B@s1c_Enc0d3}" | |
else: | |
logging.warning("IncoorectCreds") | |
msg = "Incorrect Username or Password" | |
return flask.render_template("basicAuth_challenge.html", | |
msg = msg) | |
@app.route("/sessions/challenges/tokenAuth") | |
@bauth.login_required | |
def tokenAuth_Challenge(): | |
flag = "5067{Token_Acc3pted}" | |
return flask.render_template("tokenAuth_challenge.html", | |
flag=flag) | |
@app.route("/sessions/challenges/storingState") | |
def hiddenState(): | |
username = flask.request.args.get("user") | |
isAdmin = flask.request.args.get("admin",None) | |
if username: | |
if isAdmin is None: | |
return flask.redirect(flask.url_for("hiddenState", user=username, admin=0)) | |
flag = "5067{State_Mangled_In_F0rms}" | |
return flask.render_template("urlState.html", | |
uName = username, | |
admin = isAdmin, | |
flag = flag | |
) | |