JWT Secrets
Help
This page offers a convenient way for you to interact with the "JWT Secrets" challenge functions. You can also use GET requests to send and receive data directly from the listed routes/endpoints if you wish. For more information see the FAQ.
Your aim is to recover the FLAG
value. Once you have have it, submit it on the Crypto On The Web challenge page.
Source
import jwt # note this is the PyJWT module, not python-jwt
SECRET_KEY = ? # TODO: PyJWT readme key, change later
FLAG = ?
@chal.route('/jwt-secrets/authorise/<token>/')
def authorise(token):
try:
decoded = jwt.decode(token, SECRET_KEY, algorithms=['HS256'])
except Exception as e:
return {"error": str(e)}
if "admin" in decoded and decoded["admin"]:
return {"response": f"Welcome admin, here is your flag: {FLAG}"}
elif "username" in decoded:
return {"response": f"Welcome {decoded['username']}"}
else:
return {"error": "There is something wrong with your session, goodbye"}
@chal.route('/jwt-secrets/create_session/<username>/')
def create_session(username):
encoded = jwt.encode({'username': username, 'admin': False}, SECRET_KEY, algorithm='HS256')
return {"session": encoded}