$ cat writeup.md…
$ cat writeup.md…
Hack.lu 2026
Task: pwn a Connect-Four game (x86-64 PIE, execstack) where score indices are attacker-influenced. Solution: score_ceo=6 turns player.name into a printf format string (stack leak); score_player=5 makes end_fns[-1] call a controlled 6-byte name; a read/push-ret stager is hidden in the 3-bit-packed move history.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Can you rally the team and remind the CEO who is shipping the product?
The CEO just closed a funding round and emptied a bottle of wine too much with the stakeholders. Enough slack despite the sprint to play a round of "CEOnnect Four", their favorite team alignment activity. But careful: the CEO doesn't take feedback well... Can you push to prod nevertheless?
English summary: we are given the source c4.c and a 64-bit ELF c4. It is a
Connect-Four game against a "CEO" opponent. We may play up to three games and
enter a player name each round (2/4/8-byte fgets buffers ⇒ 1/3/7 usable
characters). The binary is a PIE, dynamically linked, non-stripped, and linked
with an executable stack (-Wl,-z,execstack). The service is spawned by
ynetd through execle("/bin/sh","sh","-c","./c4",NULL,NULL), i.e. the
environment is stripped to NULL, so there is no environment-variable shortcut
and the flag lives only at /chal/flag.
The interesting parts of main are the two "score" variables and the two places
they are used as an index:
struct player_data { char name[8]; void (*end_fns[4])(void); }; struct ceo_data { char s[5][8]; }; struct hist_moves { int idx; char hist[64]; }; struct game_state { char f[6][7]; int played; struct hist_moves *hist; };
Outcomes only ever update the scores through count(), which returns the
longest run of a symbol (columns, rows, both diagonals) — not the total.
That matters, because a single move can merge two shorter runs and make the
returned value jump straight from 2/3 to 5, 6 or 7 instead of stopping at 4.
The main loop breaks when a score reaches >= 4, but the value it stored is
whatever count() returned, so it can overshoot.
...
$ grep --similar