An explosive challenge at ESAIP CTF 2024
“There’s someone in Aix-en-Provence with whom we’ve discussed a project…”
Let’s change the setting and discover the behind-the-scenes of the project carried out for the closing of the ESAIP CTF 2024.
The team: Instead of having multiple personalities as one might hear in the retrospective video of the CTF 2024, I was unfortunately the only brave knight who successfully led this project, and at my own expense.
The objective: Create a mock bomb defusal challenge using an ESP32 board.
Timeline: 3 days to design, prototype, test, and complete the final product.
Initially planned over a period of 3 months alongside my Erasmus in Finland, the components listed on the purchase and budget sheets from April 2024 were received 3 days before the event due to logistical issues.
A project carried out around 5 elements:
- An 8×8 variable color LED panel
- A 4×4 alphanumeric keypad
- 5 pairs of colored “banana” plugs
- A 16×2 I²C LCD screen
- An ESP32 Espressif S3 Devkit C microcontroller, chosen for its broader inclusion of C and C++ libraries like “Vector”
Libraries used:
- Wi-Fi library for setting the ESP-32 in access point mode.
- AsyncTCP library to allow multiple CTF administrators to connect to the configuration and monitoring interface.
Author: Me No Dev References - Keypad library to convert the resistive behavior of the keypad buttons into an ASCII letter.
Authors: Mark Stanley, Alexander Brevig References - NeoPixel library to manage the 8×8 RGB LED panel.
Author: Adafruit References
- Wire library for managing the I²C protocol.
- LiquidCrystal I²C library to manage the LCD display.
Author: Frank de Brabander References
- The first part involved solving a maze with invisible walls following a predefined pattern provided during the campaign challenges.
- The second part involved entering a code retrieved during another challenge of the influence campaign on the numeric keypad.
- The third part involved disconnecting the banana plugs in a specific order revealed in the form of a poem during the resolution of a campaign challenge.
——-
Let’s discover the behind-the-scenes.
First, I performed a simulation on the Wokwi platform to simulate the real system:
The simulation consists of the same elements as the physical system
– ESP 32 Espressif
– Keypad
– Buzzer
– 8×8 LED panel
– Switches
Thanks to Wokwi Premium, I was able to simulate the web control interface for the organizers stored in the ESP32 controller’s memory. Its use is simple:
– The organizers select a maze pattern that the participant must solve during the challenge.
– A countdown timer is set based on the chosen difficulty.
– The organizers then start the countdown. The challenge begins!
I coded the system based on a state machine principle evolving according to the user’s success in the challenges
Among these states are
– An IDLE state “ENATT” where the bomb enters configuration mode.
– A “MAZE” state where users must solve the first challenge
– A “CODE” state exhaustive in its function.
– A “CABLES” state for the cable disconnection challenge at a precise moment.
– A “KABOOM” state where the bomb fictitiously enters explosion mode.
– A “SUCCESS” mode where the bomb delivers its success flag.
Here is the skeleton of the state machine controlling the system:
Note: The “lock” state allows me to avoid refreshing the LCD screen during each clock cycle.
In terms of variables, the mazes were hard-coded into non-volatile memory:
The same applied to the web page self-hosted asynchronously (using the ESPAsyncWebServer library) by the ESP-32 set in Wi-Fi access point mode.
The first maze-solving challenge used the KeyPad library: a key press was converted into an alphanumeric character, then the player’s actual position within the maze was updated by verifying the correctness of their input.
With each correct input, the LED panel was updated by simply scanning the RGB pixels according to the row and column addressing facilitated by the Adafruit NeoPixel library: green was assigned to the entrance, red to the exit, and blue to the player.
The second challenge used the same process described for the first challenge. The user’s input was stored in a buffer variable, and upon pressing the “#” key, the combination was checked against the one stored in a non-volatile memory variable.
The third and final challenge of this CTF2024 required precision and speed from the players.
On my side, I organized my code so that no bypass attempts could be implemented.
Therefore, it had to be coded according to 3 criteria:
– The first was timing, where no wire disconnection should be tolerated before the end of the allotted time.
– The second was to allow a margin of error for the player: with a human reaction time of 250ms, 300ms of leeway was allocated at the end of the final countdown before checking the wire disconnection.
– The third was to check if the disconnected wires matched those stored in memory.
A “courtesy” display mentioned the remaining seconds before the end of a disconnection wave, which was accompanied by a sequence of beeps, adding stress to the challenge.
Conclusion & Reflection
This experience of designing a solution allowed me to develop and strengthen my skill set. In terms of skills developed, I was able to apply my knowledge in C++ and electronics. This application took place in two phases: the first extended over the design of a prototype and a virtual simulation, the second corresponded to the realization of the turnkey final product. Neither of these two phases posed any blocking points for me, the main difficulty being to manage unforeseen events and change the model in real-time. The fragility of the keyboards was put to the test during the gluing of the elements on the final support, which caused a malfunction of several keys. A simple code adjustment was enough to solve the problem.
The most complex part of this project was managing time, communication, and the project itself. Delivering on time for a project that was delayed by two months due to logistical issues was my source of motivation. I was able to develop my stress resistance, as no one on the CTF team could validate or question any aspect of the project, being the only person mastering this field within the organizing team.
In hindsight, I wish to surround myself with a team in the future to polarize my ideas and, above all, to increase the safety margin of a project. I like to push the limits of the impossible, which was put to the test during two sleepless nights, but it seems essential to me to be supported to prevent any risk and to better distribute the tasks to be carried out in future projects of a different scale.