Challenge Notebook Architecture with the Crucible API#
For simplicity, let's break down the structure of a Challenge notebook with the coolest one around, "test". This is an example to validate your API key. Think of this like a tutorial in a video game when you have to look up and jump.
-
The notebook first contains a code cell to execute the storing of your Crucible API key and some other variables for you to authenticate to the Crucible API and structure your later requests to the correct challenge.
-
Challenges will always come shipped with dependencies so ensure to install them via pip:
-
Now we have our environment loaded, we can interact with the challenge API. This is a simple request using python to make transmit a HTTP POST request to the endpoint.
-
Yargh mateys! Flags for everyone!
-
Since we have our unique flag for this challenge, let's submit it to the endpoint for some sweet kudos:
import requests def submit_flag(flag): url = f"{CRUCIBLE_URL}/api/challenges/{CHALLENGE}/submit-flag" headers = {"X-API-Key": CRUCIBLE_API_KEY} payload = {"challenge": CHALLENGE, "flag": flag} response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: if response.json().get("correct") is True: print("The flag was correct. Congrats!") else: print("The flag was incorrect. Keep trying!") else: print("There was an error submitting your flag") print(response.text) flag = "gAAAAABnJreQ5YYJ9x9m4oFdFMXUsbmH0_FmG5trWTGzVXI-TIvB9APjquiIdv8HJzRWP56Qkm1L3ef8qXf5J6Q0s3D_-d21N2r_FMjlTbtYdXwLl4IM5wD60ut5kstqsD4k0NgNzJqxVJb7Llm1QrIAHXkL54jxgcmORWlNw9t-fKvTxoQGy0g=" # Replace with the flag once you find it submit_flag(flag)
It really is that simple. These code blocks are also available in the dedicated challenge page itself if you prefer to read and interpret them from the challenge page itself. This is to give you an overview of the challenge background, skills and objective without having to leave the Crucible UI.
Try Your First Challenge#
Now that you're familiar with Challenges, you're ready to try your first one. We've crafted four introductory Challenges to set you on your way as part of the Bear series.
Learn more about how to Complete Your First Challenge.
Need any help or technical problems? Check out the troubleshooting guidance.