TexSAW CTF 2026 Return to Sender
Do you ever wonder what happens to your packages? So does your mail carrier.
nc 143.198.163.4 15858
Flag format:
texsaw{example_flag}
Solution
1. Initial Analysis
We start by analyzing the binary’s protections:
1 | $ checksec chall |
- No Stack Canary: This means we can easily overwrite the return address on the stack.
- NX Disabled: The stack is executable, but we don’t necessarily need shellcode for this exploit.
- PIE Disabled: Function addresses are static and will not change between runs.
2. Identifying Vulnerabilities
Using objdump and nm, we identify several
interesting functions:
main: The entry point.deliver: Called bymain; uses the unsafegets()function to read input into a 32-byte buffer.drive: A hidden function that checks an argument and, if correct, callssystem("/bin/sh").tool: Contains a useful ROP gadget:pop rdi; ret.
The vulnerable deliver function looks like this:
1 | int deliver() { |
Since gets() does not check the input length, we can
provide a payload larger than 32 bytes to overwrite the saved
instruction pointer on the stack.
3. Exploitation Strategy
The drive() function is our target:
1 | int __fastcall drive(__int64 a1) { |
To get a shell, we need to call drive(0x48435344). In
the x86-64 calling convention, the first argument is passed in the
RDI register.
Our ROP Chain Plan:
- Overwrite the return address with the address of a
pop rdi; retgadget. - Provide the value
0x48435344as the next item on the stack (to be popped intoRDI). - Include a
retgadget for stack alignment (often necessary forsystem()calls in 64-bit glibc). - Finally, call the
drivefunction.
4. Exploit Script
1 | from pwn import * |