DAMCTF 2025 · Reverse
RISCy Business — DAMCTF 2025
2 min read · solved 2025-05-10
| Event | DAMCTF 2025 |
| Category | Reverse engineering |
| Challenge | RISCy Business |
| Author's note | "Simple static rev challenge on an embedded RISCV device." |
| Files | esp_ota_client.elf (≈ 5.3 MB) |
| Solved by | Joker (Ridjan Xhika) |
TL;DR
The binary is ESP-IDF firmware for an ESP32-C6 (RISC-V, FreeRTOS). Find app_main, follow it into a task called build_flag_task, and read the pieces it glues together with strcat. No emulation needed.
dam{Fr33R705_15_C001_on_the_esp32c6}
Recon
First question with any unknown binary: what is it built for?
$ file esp_ota_client.elf
esp_ota_client.elf: ELF 32-bit LSB executable, UCB RISC-V, RVC, soft-float ABI,
version 1 (SYSV), statically linked, with debug_info, not stripped
Three things jump out:
- RISC-V 32-bit with compressed instructions (RVC) — not x86, so the usual muscle memory is off.
- Statically linked — the whole RTOS and SDK are inside, which explains the 5 MB.
- Not stripped, with debug info — symbol names survived. That's the gift of the challenge.
A quick strings pass confirms the platform and already leaks some interesting bits:
$ strings -n 4 esp_ota_client.elf | grep -E "app_main|build_flag|Flag|dam\{|esp32c6$"
I (%lu) %s: Calling app_main()
dam{
esp32c6
I (%lu) %s: Flag: %s
Fr33R705_15_C001
build_flag_task
So this is an ESP-IDF project (Espressif's SDK) targeting the ESP32-C6, it prints a flag through the ESP logger, and the function that builds it is literally called build_flag_task. The flag clearly isn't stored in one piece, though — we can see dam{ and a middle chunk, but not how they're joined.
Analysis
Loading it in Ghidra
Ghidra handles RISC-V 32 out of the box (no plugin, unlike some other tools), and because the binary isn't stripped the symbol tree is readable straight away.
Finding the entry point
In ESP-IDF, your application code doesn't start at main(). The SDK boots FreeRTOS, starts the scheduler, and then calls app_main() from its main task — that's what the Calling app_main() log string refers to. So app_main is where the challenge author's code begins.
Following the task
From app_main, the call chain leads straight to build_flag_task (the _task suffix is the FreeRTOS naming convention for a task function). That's where the flag is put together. Stripped of SDK noise, the logic boils down to:
// reconstructed from the Ghidra decompilation
char flag[64] = {0};
strcat(flag, "dam{");
strcat(flag, "Fr33R705_15_C001");
strcat(flag, "_on_the_");
strcat(flag, "esp32c6");
strcat(flag, "}");
ESP_LOGI(TAG, "Flag: %s", flag);
The flag is assembled at runtime from several fragments, so strings alone only shows the longer pieces; the short glue strings are easy to miss. Reading the strcat calls in order gives the full value.
Solution
file→ RISC-V 32-bit ESP-IDF firmware, not stripped.- Open in Ghidra, jump to
app_main. - Follow the call chain into
build_flag_task. - Read the
strcatsequence in order and concatenate.
Flag
dam{Fr33R705_15_C001_on_the_esp32c6}
("FreeRTOS is cool on the ESP32-C6", in leetspeak.)
Takeaways
- Run
filefirst. Knowing the architecture and whether symbols survived decides your whole approach. - Know the framework's entry point. On ESP-IDF it's
app_main, notmain— reading SDK docs saved a lot of clicking. - Static analysis was enough. A forked QEMU can emulate the ESP32-C6, but with symbols intact it would have been slower than just reading the code.
- RISC-V is showing up more in CTFs (and in real IoT devices), so it's worth getting comfortable reading it.