Major Steps Spoiler - Both Challenges
You can read from the (virtual) SPI EEPROM
Look at the source on github to discover the commands that are supported, and how they are processed.
The source on github will also show a sequence that can be used to read from the flash (in code … not the console).
Convert that into a a sequence of commands.
Precise command sequence to read from (virtual) SPI EEPROM
Let’s presume you want to start reading from the flash at address 0xAABBCC.
REM - `END` is optional, unless there was a prior command
END
REM - `RELEASE` is the opposite of `ASSERT` and ensures
REM - the SPI chip sees a transition from non-selected to selected
RELEASE
REM - `ASSERT` sets `/CS` low ... selecting the flash chip on the SPI bus
ASSERT
REM - `BEGIN` sends the start bit on the SPI bus
BEGIN
REM - `DATA` sends bytes over SPI
REM - First, send the four-byte command to read from the address
DATA 03 AA BB CC
REM - Then, read 32 bytes of data at a time
DATA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
REM - and then the next 32 bytes of data ...
DATA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
REM - Repeat ad nauseum as required
NOTE: REM is not a valid command, and used solely to comment the code
I used an AdaFruit MacroPad to generate a script that would dump all 128k of the (virtual) SPI EEPROM. Each run of the script took about an hour.
Then, I discovered I could not actually copy/paste from the text output. Luckily, the debug console had a copy of all the output, and could be copy/pasted into VSCode.
Couple that with a long sequence of search’n’replace, and I was able to find all locations in the (virtual) SPI EEPROM that stored data.
Major Steps Spoiler - Original Challenge
There is only data in one location:
The decrypted message indicates the location
on the flash where the second stage’s data is.
But I’m blocked by what might be an emulator bug
(or misconfiguration).
I cannot get the emulator to allow me
to write to the flash chip, which appears
necessary to officially progress to the next stage.
Updated thoughts on Stage 2:
Stage 2 is much easier than I thought it would be.
Solving Stage 2 also requires writing to the flash chip.
I know the data to write, and am stuck due to inability
to write in the emulated version.
Initial thoughts on Stage 3:
This is where the cryptography portion gets interesting.
Unfortunately, to make progress, the ability to write
to the flash chip is required. Maybe it’s an emulator bug,
or maybe I’m just doing stuff incorrectly…
I’ve also noticed a nice “naked” hack, likely for the endgame / last challenge. Looking forward to confirming its use for final stage!