$ cat writeup.md…
$ cat writeup.md…
fortid2026
Task: a 'GDB as a service' endpoint compiles/loads an attacker ELF and runs `disassemble <name>` with a strict char filter, printing only stdout. Solution: abuse `disassemble /s` source-interleaving to read flag.txt by crafting an ELF whose DWARF source filename is flag.txt, turning legitimate GDB output into an arbitrary file read.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Get your mains disassembled. (GDB-as-a-Service)
English summary: A TLS network service (ncat --ssl, port 1337) exposes GDB as a
service. The client supplies a base64-encoded ELF and a "function name"; the
server disassembles that function and returns the output. The flag lives in a
file the service can see, and the goal is to make GDB leak it.
The server (server.py) flow is:
len(b64) < 30KB), b64decode it, write to tmpdir/a.out, chmod 755.function_name string. Reject if len >= 30 or any char is in BAD_CHARS.flag.txt into tmpdir (next to a.out).gdb -ex "disassemble {function_name}" -ex quit a.out and print the result
via subprocess.check_output — stdout only; GDB stderr is discarded.BAD_CHARS blacklist (everything else is allowed):
NUL CR LF TAB ; | & ` $ < > \ ' " ! # , ( ) [ ] { }
So the allowed set includes: space, % * + - . / 0-9 : = ? @ A-Z ^ _ a-z ~.
Two important facts about the environment:
chdir, so GDB's current working directory is the
server directory, where a second real flag.txt also exists (in addition to the
copy placed next to a.out)..debug_gdb_scripts inlined Python (type-4 entry). Embedding a Python
script in the ELF that runs open('flag.txt').read() on objfile load is
declined by GDB's default auto-load safe-path ($debugdir:$datadir/auto-load).
The refusal warning goes to stderr, which the server never captures, so it
fails silently. Confirmed against gdb 16.3/17.1 locally....
$ grep --similar