$ cat writeup.md…
$ cat writeup.md…
Securinets CTF Quals 2026
Task: memcpy(dst, buf+0x80, n) with signed count checked only as n > 0x70, then movsxd-extended. Solution: negative count becomes huge size_t; glibc memmove's wrapped 32-byte store clobbers caller frames; 2-byte partial overwrite + PIE low-16 brute force reaches ret2win system("/bin/sh").
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
nc pwn3.securinets.tn 1000— pwn.red/jail wrapper,JAIL_TIME=60, flag at./flag.txtin the challenge cwd (/srv/app). Handout:main,libc.so.6(Ubuntu GLIBC 2.39),ld-linux-x86-64.so.2,Dockerfile,docker-compose.yml.
English summary: a stack challenge with no menu. main owns a 0x70-byte stack
buffer and asks for a string plus a count of characters to copy into it. The
count is validated with a signed upper-bound check only, then passed through a
sign-extending movsxd into memcpy's size_t argument — a negative count turns
the copy into a gigantic memmove whose wrapped tail store lands inside caller
frames. Goal: get a shell and read flag.txt.
main (PIE, canary, NX, partial RELRO, not stripped, interp ./ld-linux-x86-64.so.2,
shipped Ubuntu GLIBC 2.39):
setup(): setbuf(stdout, NULL) / setbuf(stdin, NULL) — both streams unbuffered.prompt(buf): puts("Welcome to Securinets Quals!"), puts("Let's start off easy"), then input(buf). No canary in this frame.input(buf): prints "Say your wise words: " and "How many wise chars do you want to say: ", scanf("%d", &n) into int n at rbp-0xf4, if (n > 0x70) exit(0) (signed compare — only rejects greater-than), read(0, buf, 0xe0) into char buf[0xe0] at rbp-0xf0, then
memcpy(dst, buf + 0x80, (size_t)(long)n) — the count is loaded with movsxd rdx, eax (the sign-extension bug).main: printf(escape(buf)), where escape() mallocs a copy with every % doubled — the format string is a decoy.win() @ PIE+0x121c: puts("GG"); system("/bin/sh"), "/bin/sh" at .rodata 0x200b.
win+0x13 = PIE+0x122f: lea rax,[rip+0xdd5]; mov rdi,rax; call system@plt — the correct ret2win entry (skips puts("GG"), and %rsp is 16-byte aligned there)....
$ grep --similar