Forensic
Baby SoC (256 pts)
Description
We found really funny device. It was broken from the beginning, trust us! Can you help with recovering the truth?
Solution
Given flashdump.bin, parse the executable using this parser. There will be issue if we use the newer version of esptool library, use this patch to solve the issue. First, take a look on available partition on the flashdump.bin
python3 esp32_image_parser.py show_partitions flashdump.bin
Dump app0 executable using create_elf argument.

Use ghidra to decompile the ELF file. Looking at available strings that there is "Flag" string.

As we can see on line 12 there is code like an string builder that result <h2>Flag: ??? </h2>. So we can assume that auStack_6c is the variable that store the flag. auStack_6c copied from auStack_49 that constructed from FUN_400d293c. Take a look on FUN_400d293c.
FUN_400d293c do xor for two static values which are DAT_3ffbdb68 and DAT_3ffbdb8d. To get the flag we just need to do xor for those static values.

Flag: justCTF{you_x0r_me_r1ght_r0und_b4by}
Budget SoC (363 pts)
Description
We've obtained a mysterious device. Our forensic team tried to retrieve the original source code, but something went wrong. Fortunately, we managed to dump the memory into a file. Can you find what we need?
Solution
Given flashdump.bin, parse the executable using this parser. There will be issue if we use the newer version of esptool library, use this patch to solve the issue. First, take a look on available partition on the flashdump.bin.

Dump app0 executable using create_elf argument.
Open it using ghidra and look at string "flag" we will found reference to the function that will produce flag like in previous SOC challenge.

Rename some variable and function to make it easier to understand.
So the ciphertext are processed on function FUN_400d296c, next take a look on function FUN_400d296c. There are some constant in the function so it nice to search it on github.

Search for the constant in 4 bytes format, https://github.com/search?q=0x52096ad5&type=code and i found this.
From above code we can see that the constant is actually from aes decrypt process. Looking at another function looks like it is same like in the app0.elf function. So the last step is basically finding the key and the ciphertext used by the function in app0.elf.
From the caller function we get the key, which is on the fifth argument (DAT_3ffbdb68). The ciphertext is on second argument and it allocated from function allocation_ that we assume the data is from _DAT_3ffc3e38.
Looking at ELF file, we know that _DAT_3ffc3e38 is not stored on it.

So we assume that the data is maybe on runtime memory. Because we have the flashdump.bin we try to directly find the ciphertext by bruteforcing all 32 bytes value in the flashdump.bin. Below is our script to do bruteforce.

Looks like we got partial flag, so the mode should be not ECB. The next step we do is trying to use AES CBC with iv null bytes, because the first block is already correct plaintext.

Flag: justCTF{dUmp3d_r3v3rs3d_h4ck3d}
Last updated