Solve a CTF flag checker
The handout is a 15,248-byte stripped x86-64 ELF. It asks for a flag and prints Correct! or Incorrect!. REA follows the prompt to the checker, lifts 26 mask equations, and a small Python script finds an input the original program accepts. The contest is DownUnderCTF 2023, authored by joseph and published in the organizers’ challenge repository. The event is closed, so this page records the historical flag with that framing.
Find the checking function
Start with strings. The prompt, the rejection, and the acceptance message are enough to reach the code that decides.
Use REA to analyze ms_flag_checker and find the flag. Explain how the checks work, then verify the answer with the original program.
open_binary
{"path": "ms_flag_checker"}
search_strings
{"pattern": "flag|correct|wrong|input",
"mode": "regex", "case_sensitive": false}
xrefs
{"address": "0x102004"}
resolve_containing_procedure
{"address": "0x10126d"}
0x102004 "What is the flag? "
0x10201c "Incorrect!"
0x102027 "Correct!"
Prompt referenced at: 0x10126d
Containing function: 0x10124d
The binary is stripped, so the cross-reference is the way in. Addresses are in REA’s imported image. The file on disk is the organizer ELF with SHA-256 dcd3bec4f608e11f3a12ce461100aaf5f621851ee63a1f870d7c90d4e3dd51ae. This site does not mirror that binary; the footnote points at the organizers’ raw file.
Thirty-six characters, twenty-six sums
Reading 0x10124d plus helpers 0x101189 and 0x101217 shows two loops. The first copies 36 character codes. The second decodes a mask, sums the selected codes, and compares the sum with a stored integer.
0x1012c1: CMP EDI, 0x24
0x1012c6: LEA RBX, [0x1040e0]
0x1012cd: LEA RBP, [0x104060]
0x1012d4: LEA R13, [RBX + 0x270]
0x1012e1: CALL 0x00101189
0x1012ec: CALL 0x00101217
0x1012f1: CMP dword ptr [RBP], EAX
0x1012f4: JNZ 0x00101335
0x1012f6: ADD RBX, 0x18
CMP EDI, 0x24 is the length check: 0x24 is 36. The checking loop steps RBX by 0x18 bytes across a 0x270-byte mask table, which is 26 masks. A mismatch jumps to Incorrect!.
One check reveals one character
The input is a 6×6 grid. A mask is stored as signed run lengths: a negative run skips cells, a positive run selects them, and zero stops. The figure above is the seventh mask, which selects a single cell.
Bytes at the seventh mask and its target:
read_bytes
{"address": "0x1040e0", "length": 624}
{"address": "0x104060", "length": 144}
Mask at 0x104170:
eb 01 f2 00 → -21, +1, -14, stop
Target at 0x104078:
37 00 00 00 → 55
MOVSX is why eb means −21 rather than 235. Skip 21 cells, select one, skip 14. The selected index is 21, and the little-endian target is 55, so code[21] = 55, the character 7. Most other masks select many cells at once. The first requires 16 character codes to sum to 1441. Overlap is what makes the system solvable.
From the summing helper to C
The helper at 0x101217 walks 36 integers. ECX is the running total. A zero mask cell skips the character; a nonzero cell adds codes[i]. The caller compares EAX with the stored target.
0x10121c: MOV ECX, 0x0
0x10122c: CMP dword ptr [RSI + RAX*0x1], 0x0
0x101230: JZ 0x00101223
0x101232: ADD ECX, dword ptr [RDI + RAX*0x1]
0x101223: ADD RAX, 0x4
0x1012f1: CMP dword ptr [RBP], EAX
0x1012f4: JNZ 0x00101335
int check_one_mask(const int codes[36],
const int mask[36],
int target) {
int total = 0;
for (int i = 0; i < 36; ++i) {
if (mask[i]) total += codes[i];
}
return total == target;
}
The C flattens the 6×6 grid into 36 cells and uses descriptive names. It is an explanation of the helper and its caller, not a claim that the stripped binary shipped those identifiers.
Solve the 26 equations
Z3 searches for character codes inside a conventional flag alphabet that satisfy every extracted sum. The prefix DUCTF{ and a closing brace are format assumptions, checked afterwards by running the ELF. The full mask table is in the self-hosted script solve.py.
from z3 import Int, Or, Solver, Sum, sat
codes = [Int(f"code_{i}") for i in range(36)]
solver = Solver()
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_{}"
for code in codes:
solver.add(Or(*[code == ord(c) for c in alphabet]))
for code, char in zip(codes, "DUCTF{"):
solver.add(code == ord(char))
solver.add(codes[-1] == ord("}"))
for selected, target in checks:
solver.add(Sum([codes[i] for i in selected]) == target)
python3 -m venv .venv
.venv/bin/python -m pip install z3-solver
.venv/bin/python solve.py
Solving needs Python 3 and z3-solver. Running the original executable needs Linux x86-64. Paste the script’s candidate at the program’s prompt.
The original program answers Correct!
A process capture of the organizer ELF accepts the solved input and rejects a one-character edit. Changing one selected z to y drops the first sum from 1441 to 1440, and the program prints Incorrect! with exit status 255.
| Input | Observed output | Exit code |
|---|---|---|
| Solver’s flag | Correct! | 0 |
| One character changed | Incorrect! | 255 |
Archived contest result, recorded after the 2023 event closed. The original program prints:
What is the flag? DUCTF{ezzzpzzz_07bcda7bfe81faf43caa}
Correct!
That string also matches the flag in the organizers’ published challenge metadata, compared after the binary had already been solved. Strings, functions, and constants were read from the ELF before opening the organizers’ source. The diagram and solve.py were built from those extracted checks.
Fresh analysis and two process captures used REA 4.1.0 with Ghidra 12.1.4 on Linux x64, on 8 October 2026. Republishing this flag is limited to the archived handout. It is not a live-contest spoiler, and the same summing trick is not a method for software you were not given to solve.
Next step
Similar browser session records can become AgentEnv replay environments
This case is not a claim that it is a specific Hugging Face environment. When REA records an authorized browser session, Scale AgentEnv can expose replay as MCP tools. rea.run mirrors the catalog only — we do not host the RL runtime.
Environments catalog → What is AgentEnv + REA? HF collection ↗ Introducing AgentEnv
Compliance
DownUnderCTF 2023 is an archived contest. The historical flag below is the string the original program accepts and the string the organizers published after the event. Do not treat contest technique as permission to attack software outside the handout.
Takeaways
- The prompt’s cross-reference names the checker even when symbols are gone.
- 26 overlapping masks on 36 cells are a constraint system, not 26 independent compares.
- The archived flag is the one input that makes this ELF print Correct!.
- Contest authorization ended with the event. Leave production binaries alone.
More on-site cases