d4rk{four_scenes_later}


A 300-point challenge that demands a full GBA ROM teardown — state machine, RSA-chest UI, RC4 routine — before the real puzzle, a constructed-language cipher, even begins.
Summary
Salads_life.gba is a real GBA ROM (devkitARM crt0, Thumb game code, header title
SALADS SIGHT) whose chest screen wants a single-digit key. The key is 4: the chest
displays PUB KEY E: 65537, and 65537 = 0x10001 = F4, the 4th Fermat number — the
"secure number starting with 'f'" from the description. The same digit 4 is then reused
as a single-byte RC4 key for a 9216-byte blob at ROM 0x5744, which decrypts to the
"genuine artifact" painting — a 192x48 8bpp mode-4 bitmap. The painting is not really a
picture: it is written in SceneScript (an r/neography constructed script where each
letter is a scenery element). Reading the glyphs gives ciphertext JSYV WGIRIW PEXIV, and
because "Mr. salad" is Caesar and the key 4 is reused ("IS IT THE ONLY PLACE WHERE THE
KEY IS USED THO?"), shifting back by 4 yields FOUR SCENES LATER — the flag.
Handout: Salads_life.gba (31560 bytes). Flag format: d4rk{...}.
Solution / Exploit
1. ROM structure (fully reversed)
Real GBA ROM: entry at 0x08000000 is ARM b 0x080000C0 (devkitARM crt0), then the game
is Thumb. GBA header title at 0xA0 = SALADS SIGHT / gamecode 2D2B / 01.
State machine: a dispatch at 0x080002EA reads state = *(u8*)(struct+0x5D) and jumps
through the handler table at ROM 0x4C64:
| state | handler | meaning |
|---|---|---|
| 0 | 0x08000A00 | title ("SALAD GOES SIGHT SEEING / A 2-BIT PLATFORMER / PRESS START OR A") |
| 1 | 0x08000B6C | walking / level |
| 2 | 0x080006F0 | RSA-1024 chest UI |
| 3 | 0x08000460 | "YOU FOUND THE PAINTING! / # GENUINE ARTIFACT #" + painting |
| 4 | 0x08000F7C | "MOCK PAINTING #2" decoy screen |
Key globals: struct base 0x02000084; painting RAM buffer = 0x020000FC (9216 bytes);
0x02000008 holds the accepted key (value 4).
The state machine and screens were mapped by driving the ROM in a Unicorn-based emulator
with a stubbed DMA controller and a mode-4 renderer (k_emu.py, salad_states.py,
salad_force.py); the forced chest run logs every draw-string and state transition
(k_chest_forced.txt).
2. The chest and the key
Chest screen strings (ASCII in ROM, 0x4A9C…0x4C60):
* RSA-1024 CHEST *
ENCRYPTION: RSA-1024
PUB KEY E: 65537
N: 0XB4A7C93E10F82D5B...
C: 0X7F3A902E4C18D35F...
ENTER THE KEY TO / OPEN THE CHEST / [A] UNLOCK [B] CANCEL
YOU FOUND THE PAINTING! / # GENUINE ARTIFACT #
OH.. U GOT IT, / IS IT THE ONLY PLACE WHERE THE KEY IS / USED THO?
MOCK PAINTING #2 / MOCK #2 / DECOY
DECOY RSA KEY ENTERED! / NOT THE REAL PAINTING. / TRY THE CHEST AGAIN!
The chest UI is a single-digit spinner (+1 % 10 on UP/RIGHT, +9 % 10 on DOWN/LEFT,
confirm on A/START). At 0x08000734:
cmp r0, #4 ; r0 = selected digit
bne skip
bl 0x08001FD4 ; success path
skip:
ldr r3,[r4,#4] ; r4 = 0x02000004 -> [0x02000008] == 4
cmp r0,r3
bne …
bl 0x08001FD4
… state = 4
So the chest key is 4 (both the hard-coded compare and the global agree on 4).
E = 65537 = 0x10001 = F4, the 4th Fermat number — that is the "secure number
starting with 'f'", and F4 → digit 4 → the key. That is the "key reuse" the game teases
("IS IT THE ONLY PLACE WHERE THE KEY IS USED THO?").
3. Success path (0x08001FD4)
divmod(digit,10) ; digit = 4
buf[0] = remainder + '0' ; "4"
buf[1] = 0
memcpy(0x020000FC, 0x08005744, 0x2400) ; 9216 bytes ROM -> EWRAM
rc4_inplace(buf) ; <-- key = the ASCII digit string
struct+0x68 = 1 ; "painting loaded" flag
state = 3
0x08002CB0 is the RC4 routine: standard KSA/PRGA over a 256-byte stack S-box,
XORing 9216 bytes at 0x020000FC in place, key = buf (only key[0] is ever used).
So the effective key is the single byte '4' = 0x34.
4. Painting extraction
salad_solved/extract_painting.py reproduces it:
1ROM = open('Salads_life.gba','rb').read()
2ct = ROM[0x5744:0x5744+0x2400] # 9216 bytes, entropy 7.98 (encrypted)
3pt = rc4(ct, 0x34) # RC4, single-byte key '4' (int, not b'4')
The full extractor/renderer:
1#!/usr/bin/env python3
2"""
3Salad's life (h4ckc0n 2026) - painting extractor / renderer.
4
5The chest key is the digit 4 (F4 = 65537 = e). The same digit '4' is the
6single-byte RC4 key for 9216 bytes at ROM 0x5744; the plaintext is the
7"genuine artifact" painting, drawn on screen as a 192x48 8bpp mode-4 bitmap.
8"""
9import collections, os
10import numpy as np
11from PIL import Image
12
13ROM_PATH = os.path.join(os.path.dirname(__file__), "..", "Salads_life.gba")
14OUT = os.path.dirname(__file__)
15KEY = 0x34 # '4'
16OFF, LEN = 0x5744, 0x2400
17
18# GBA mode-4 palette as loaded by the game (dumped from 0x05000000 at runtime)
19PAL = {0x00: (24, 64, 112), 0x01: (192, 232, 152), 0x10: (40, 96, 80)}
20
21
22def rc4(data: bytes, kb: int) -> bytes:
23 S = list(range(256)); j = 0
24 for i in range(256):
25 j = (j + S[i] + kb) & 0xFF
26 S[i], S[j] = S[j], S[i]
27 i = j = 0; out = bytearray()
28 for b in data:
29 i = (i + 1) & 0xFF
30 j = (j + S[i]) & 0xFF
31 S[i], S[j] = S[j], S[i]
32 out.append(b ^ S[(S[i] + S[j]) & 0xFF])
33 return bytes(out)
34
35
36def main():
37 rom = open(ROM_PATH, "rb").read()
38 ct = rom[OFF:OFF + LEN]
39 pt = rc4(ct, KEY)
40
41 c = collections.Counter(pt)
42 print("ciphertext entropy : encrypted blob at 0x%04x" % OFF)
43 print("plaintext histogram:", dict(c))
44
45 # 192 x 48, 1 byte per pixel, real palette
46 a = np.frombuffer(pt, dtype=np.uint8).reshape(48, 192)
47 rgb = np.zeros((48, 192, 3), dtype=np.uint8)
48 for y in range(48):
49 for x in range(192):
50 rgb[y, x] = PAL.get(int(a[y, x]), PAL[0])
51 Image.fromarray(rgb).resize((192 * 5, 48 * 5), Image.NEAREST).save(
52 os.path.join(OUT, "genuine_painting_192x48.png"))
53 print("wrote genuine_painting_192x48.png")
54
55 open(os.path.join(OUT, "painting_decrypted_9216.bin"), "wb").write(pt)
56
57
58if __name__ == "__main__":
59 main()
Result: 8501/9216 bytes are 0x00, 706 bytes are 0x01, 9 bytes are 0x10
(9216 − 715 = 8501). The ROM blob equals the RC4('4') keystream for exactly those 8501
zero bytes — the strongest confirmation that key '4' is correct; every other key yields
pure noise.
Rendering (confirmed against the real in-game screen bitmap at framerow = base + r*240,
memcpy(fb_row, &paint[r*192], 192) for 48 rows):
The painting is 192 x 48, 8bpp, mode-4 bitmap, palette index 0/1/16 = dark blue / pale
green / dark green. See salad_solved/genuine_painting_192x48.png.
An emulator (Unicorn + DMA) run of the patched ROM reaching the genuine screen produced
salad_solved/screen_genuine.png — "YOU FOUND THE PAINTING!" + framed artwork +
"# GENUINE ARTIFACT #". Screen is mode 4, VRAM page 1 (DISPCNT=0x414).
5. The two paintings
- GENUINE (
state 3): the 192x48 green bitmap above — a very wide (4:1) sparse line-art landscape: on the left an umbrella/mushroom-like canopy with a banded "skirt" (X marks) and a long S-curve; a large arch/hill; then a row of rounded bumpy "tree/foliage" masses and one triangular (conifer-like) shape. - MOCK #2 / DECOY (
state 4): a different scene drawn from sprites — crescent moon, scattered stars, a tall spire/monument with radiating lines, and a row of buildings. This is unmistakably "The Starry Night" (Van Gogh) pastiche. Seesalad_solved/screen_mock2.png/mock_painting_2_zoom.png.
The mock being a recognisable famous painting confirms the genuine one is meant to be identified too, and that the "artifact" framing is the point of the challenge.
6. Hint mapping
| hint | reading |
|---|---|
| "secure number starting with 'f'" | Fermat number F4 = 65537 = e (literally shown in-game) |
the key 4 |
F4 → 4 (the digit the chest wants) |
| "IS IT THE ONLY PLACE WHERE THE KEY IS USED THO?" | the same 4 is the RC4 key for the painting 9216-byte blob |
| "a recent attack" | Fermat's factorisation / a modern factoring result on RSA |
| "geography" | identify the place depicted by the painting (the painting is the "sight" being seen) |
| "Mr. [name ~ salad]" | the painter (e.g. Salvador Dalí — "Salvador" |
| "neo*sub" | still unresolved; most consistent reading is a substitution-cipher hint ("neo-" + "sub(stitution)", narrator jokes about a "subway sub") |
7. Final step — the painting is text (SceneScript)
"neo* sub" + "geography" = r/neography. The painting is written in SceneScript
(the r/neography post "Behold, SceneScript!", key saved as
behold-scenescript-v0-3qj9v6tb662e1.webp): each letter is a scenery element.
Glyphs in the painting, left to right:
| glyph | SceneScript letter |
|---|---|
| snow cloud | J |
| big smooth arc | S |
| bridge over river (inside the arc) | Y |
| small plant | V |
x mark |
space |
| three small trees | W |
| rain cloud | G |
| small tree | I |
| river curl | R |
| small tree | I |
| three small trees | W |
_ mark |
space |
| single bush | P |
| single pine | E |
| tall plant | X |
| small tree | I |
| small plant | V |
Ciphertext: JSYV WGIRIW PEXIV. "Mr. salad" = Caesar, and the key 4 is reused
("IS IT THE ONLY PLACE WHERE THE KEY IS USED THO?") → shift back by 4:
FOUR SCENES LATER
8. Status
DEFINITELY SOLVED
- full ROM reverse (state machine, chest UI, success path, RC4 routine, draw routine)
- key
4/E = 65537 = F4relationship - exact 9216-byte painting blob, exact RC4 decryption, exact on-screen geometry/palette
- both paintings extracted and rendered; mock = "Starry Night"
- the painting decoded as SceneScript → Caesar(−4) →
FOUR SCENES LATER
9. Files
salad_solved/
genuine_painting_192x48.png exact decrypted painting, real palette
genuine_painting_dilated.png same, dilated for legibility
genuine_zoom.png / genuine_half_L.png / genuine_half_R.png
screen_genuine.png real emulated screen, state 3
screen_mock2.png real emulated screen, state 4 (MOCK PAINTING #2)
mock_painting_2_zoom.png
painting_encrypted_rom5744.bin ROM blob (9216 B)
painting_decrypted_9216.bin RC4('4') plaintext
Flag(s)
d4rk{four_scenes_later}
The format is d4rk{...} — with no c0de suffix.
Notes / Pitfalls
- The chest only shows truncated RSA values. The chest prints only the top 64 bits of
NandC(B4A7C93E10F82D5B…,7F3A902E4C18D35F…). Those 64 bits are not enough to factorN, and the fullN/Care not stored anywhere in the ROM — searched as big-endian and binary, as ASCII, and against all 54 RSA-challenge numbers (no match: RSA-1024 hex isC05748BBFB5ACD7E…, RSA-896C7A85633…). The displayedN(as a bare 64-bit value) factors as5·31·37·1373·21647·76371103— not a valid RSA modulus, so it is genuinely truncated. The RSA values are a dead end; the key is the Fermat-number hint, not a factoring attack. - "Key reuse" is literal. The same digit
4that opens the chest is the RC4 key for the painting blob — the game's own taunt ("IS IT THE ONLY PLACE WHERE THE KEY IS USED THO?") is the pointer to the second use. - The RC4 key is the byte
0x34, i.e. the ASCII digit'4', and onlykey[0]is ever used — passingb'4'or a different-length key changes the KSA and produces noise. - The mock painting is a decoy (state 4, "Starry Night") — do not try to read text out of it. The genuine artifact (state 3) is the one that carries the SceneScript glyphs.
- "neo*sub" remained unresolved during the solve; the reading that worked was
"neo-" + "sub(stitution)" → r/neography / a substitution cipher. The final decipher is
Caesar (because "Mr. salad" = Caesar) with the reused key
4.