walk

Pwn • 100 points (Static) • Easy

A courier crossed the city once and left only the map. Retrace the route exactly. Target: https://cyber-arena-2026.s3.ap-south-1.amazonaws.com/scs/binary/chall4/walk Launch Target Submit Flag*

Dr.Binary
run_sandbox
todo_write
run_sandbox
run_sandbox
run_sandbox
run_sandbox
run_sandbox

Only two challenge strings exist: route> and you walked into a wall. Time to disassemble and find what route is accepted.

run_sandbox
run_sandbox

main is at 0x401660. Let me decompile it with Ghidra.

run_sandbox

main is small and clear. Let me decode it: it reads a route string, walks a 3D map with per-cell direction bitmasks, requires landing at (6,6,6) in exactly 56 chars, then FNV-1a-hashes the route and XOR-decrypts a 40-byte flag. Let me extract the data tables.

run_sandbox

Messages confirmed: route> , \r\n, you walked into a wall, you are not there yet, you got there, but not the way the courier did. Now the jump table and data tables:

run_sandbox

Direction table decoded — chars d,e,n,s,u,w map to the 6 handlers (compass: n/s/e/w + up/down), start cell hardcodes mask 0x10 (must step up first), goal is (6,6,6), route must be exactly 56 chars, then FNV-1a hash XOR-decrypts 41 bytes at 0x497fb9. Now a solver:

write_file
run_sandbox

DFS exploded — the maze likely has many open paths. Switch to DP over (cell, remaining steps) to count and prune, then enumerate only viable routes:

write_file
run_sandbox

One unique 56-step route, and its hash decrypts cleanly. Verify against the real binary:

run_sandbox
todo_write

Solved. Flag: CACTF{bfs_thr0ugh_th3_s3v3n_cub3d_c1ty}

How it works

The stripped static binary (main @ 0x401660) is a 3D maze walk:

  1. Read a route with fgets into 0x4aa2e0, strip \r\n.
  2. Walk a 7×7×7 cube — map of direction bitmasks at 0x497e60 (343 bytes), indexed x + 7y + 49z. A jump table at 0x47c070 maps chars d,e,n,s,u,w to handlers (compass + up/down):
    • e→x+1 (bit 0x04), w→x−1 (0x08), s→y+1 (0x02), n→y−1 (0x01), u→z+1 (0x10), d→z−1 (0x20). Any other char → "you walked into a wall".
    • The start mask is hardcoded to 0x10, so the first step must be u (up).
  3. Landing check: must end at exactly (6,6,6) (else "you are not there yet") and the route must be exactly 56 chars (else "you got there, but not the way the courier did").
  4. Flag decrypt: FNV-1a over the route — with a quirk: it hashes route[55] first, then route[1..55] (byte 0 never hashed, byte 55 twice). The resulting 64-bit hash seeds h = h*prime ^ i, taking the top byte each round, XORed against the 41-byte table at 0x497fb9, then puts.

Solution

A DP over (cell, remaining-steps) showed exactly one 56-step route from (0,0,0)→(6,6,6), so enumeration was trivial once pruned:

ueswuesdwuseseuunussusdddwneuenneunuswsedwseuwsedendesuu
$ echo 'ueswuesdwuseseuunussusdddwneuenneunuswsedwseuwsedendesuu' | ./walk
route> CACTF{bfs_thr0ugh_th3_s3v3n_cub3d_c1ty}

Solver script is in solve.py (workspace).