d4rk{r3turn_0f_r3m_40}
Summary
parcel_delivery.exe is a PE32+ built by MinGW-w64 g++ 16.1.0 that ships full DWARF debug
info, so all function names survive and reversing is almost source-level. It takes a
tracking ID as argv[1] and a 16-character "recovery code" on stdin. The tracking ID must
equal a hardcoded literal (VALID_TRACKING), and the recovery code must be the unique 4×4
Latin square on digits 1–4 that satisfies per-row and per-column constraints plus four
pinned cells. On success it prints the flag as ENCRYPTED_INNER[i] ^ input[i] between
d4rk{ and }. Everything is derivable statically, and the flag was confirmed by running
the binary under Wine.
Solution / Exploit
1. Function map
objdump -d --demangle gives readable symbols:
1400014b0 verify_line(unsigned char, unsigned char, unsigned char, unsigned char)
140001568 check_lattice(std::string const&)
14000181f handle_death(int)
1400018f3 main
140001b64 __tcf_ZL14VALID_TRACKING (dtor of VALID_TRACKING)
140001b82 __tcf_ZL13RE_ZERO_FACTS
2. Tracking ID (main @ 0x1400018f3)
main builds a std::string from argv[1] and compares it to the global VALID_TRACKING
(std::operator!=, 0x140004520). The literal lives at .rdata 0x140006741:
$ python3 -c "d=open('parcel_delivery.exe','rb').read();print(d[0x3e00+(0x140006741-0x140006000):][:32])"
b'woah_a_rezero_mystery\x00...'
→ TRACKING_ID = woah_a_rezero_mystery (the invoice tracking ID from the "Love is a secret
key" web challenge; the binary is authoritative — it is the exact literal it compares against).
3. The "lattice" (Recovery code) — check_lattice @ 0x140001568
The input must be length 16, every char in '0'..'4'.
Pinned cells. Four cells are forced by sudoku[] (std::array<unsigned char,16> at
.rdata 0x140006000) XORed with DEATH_KEY and then NOT-ed:
1140001634: movzbl DEATH_KEY,%eax
214000163b: xor %edx,%eax ; sudoku[i] ^ DEATH_KEY
314000163d: not %eax
414000163f: mov %al,-0x21(%rbp) ; t
5140001642: cmpb $0x0,-0x21(%rbp)
6140001646: je skip ; t==0 -> cell unconstrained
7... cmp %eax,%edx ; else input[i]-'0' must == t
DEATH_KEY = RE_ZERO_FACTS.size() & 0xff; the RE_ZERO_FACTS table holds 40 Re:Zero
trivia strings ⇒ DEATH_KEY = 0x28. With
sudoku = d7 d7 d6 d7 d7 d7 d7 d7 d7 d3 d7 d4 d7 d7 d7 d3
the forced cells are {2:'1', 9:'4', 11:'3', 15:'4'} (all other bytes XOR to 0xff ⇒
unconstrained).
Line constraints. Every row and every column must satisfy verify_line (0x1400014b0):
a + b + c + d == 10
a * b * c * d == 24
a² + b² + c² + d² == 30
That uniquely characterises the multiset {1,2,3,4}, so the grid must be a 4×4 Latin square
on digits 1–4. With the four forced cells, brute force gives exactly one solution:
lattice (Recovery code): 4312324114232134
4. Flag derivation (main @ 0x140001a7c)
On a valid lattice, main prints FLAG: d4rk{, then for i = 0..15 prints
ENCRYPTED_INNER[i] ^ input[i] as a char, then }:
1140001a80: lea ENCRYPTED_INNER,%rcx ; .rdata 0x140006010
2140001a8f: movzbl (%rax),%eax ; enc[i]
3140001a9f: call std::string::operator[] ; input[i] (ASCII digit)
4140001aa7: xor %ebx,%eax ; enc[i] ^ input[i]
5140001ab6: call operator<<(ostream&, char)
ENCRYPTED_INNER = 46 00 45 47 41 5c 6b 01 57 6b 40 00 5f 6e 07 04
XOR with 4312324114232134 (ASCII) ⇒ r3turn_0f_r3m_40.
The whole static derivation is in solve_lattice.py:
1rows = [p for p in itertools.permutations(range(1, 5)) if verify_line(*p)]
2sols = []
3for combo in itertools.product(rows, repeat=4): # 4 rows
4 if any(not verify_line(*(combo[r][c] for r in range(4))) for c in range(4)):
5 continue # columns must match too
6 grid = [combo[r][c] for r in range(4) for c in range(4)]
7 if all(grid[i] == v for i, v in forced.items()):
8 sols.append(combo)
9assert len(sols) == 1
10lattice = "".join(str(d) for row in sols[0] for d in row)
11inner = "".join(chr(ENCRYPTED_INNER[i] ^ ord(lattice[i])) for i in range(16))
12print("FLAG:", f"d4rk{{{inner}}}")
5. Proof — real run under Wine
The binary needs the MinGW runtime DLLs (pulled from the Ubuntu
gcc-mingw-w64-x86-64-posix-runtime and mingw-w64-x86-64-dev packages, placed next to the
exe): libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll.
$ printf '4312324114232134\n' | wine parcel_delivery.exe woah_a_rezero_mystery
[+] Tracking verified: woah_a_rezero_mystery
Recovery code>
[★] The lattice glows. The memories return...
FLAG: d4rk{r3turn_0f_r3m_40}
(Full output saved in wine_run.txt, exit code 0.)
The checker also accepts an empty Recovery code> on EOF with no flag, and a wrong ID prints
"The parcel scanner does not recognise that tracking ID." — matching the disassembly.
6. Independent re-verification
A throwaway harness re-derived everything without reusing solve_lattice.py constants: it
walked the real PE section table to find .rdata, read ENCRYPTED_INNER / sudoku /
VALID_TRACKING from the file, counted RE_ZERO_FACTS literals in the binary to get
DEATH_KEY = 40, brute-forced the Latin square independently, then executed the exe under Wine:
TRACK='woah_a_rezero_mystery' ENC=46004547415c6b01576b40005f6e0704 SUD=d7d7d6d7d7d7d7d7d7d3d7d4d7d7d7d3 DEATH_KEY=40 (40 facts)
forced: {2: 1, 9: 4, 11: 3, 15: 4}
lattice=4312324114232134 derived FLAG=d4rk{r3turn_0f_r3m_40}
wine stdout: [+] Tracking verified: woah_a_rezero_mystery | Recovery code> | [★] The lattice glows. The memories return... | FLAG: d4rk{r3turn_0f_r3m_40}
VERIFIED: static derivation == wine run == expected flag (wine exit 0)
Three independent routes agree: static byte derivation, solve_lattice.py, and the live Wine
execution.
Flag(s)
d4rk{r3turn_0f_r3m_40}
Notes / Pitfalls
- DWARF symbols are intact. MinGW-w64 g++ 16.1.0 left full debug info in the PE, so you do
not have to guess function boundaries —
objdump -d --demanglenamesmain,check_lattice,verify_line,handle_deathdirectly. DEATH_KEYis derived, not stored. It isRE_ZERO_FACTS.size() & 0xff=0x28(40 Re:Zero trivia strings). Thesudoku[]bytes are meaningless until you XOR0x28and NOT them; only four cells survive as constraints.- No web exploitation was needed. The
/love/trackendpoint (username + order_id → tracking ID) belongs to the "Love is a secret key" challenge; here the binary hardcodes the expected tracking ID, so you just read it out of.rdata. - Flag format is the plain
d4rk{...}(noc0desuffix) — the brief's format exception. - Runtime DLLs. The exe will not start without the three MinGW DLLs beside it.