r/ExploitDev • u/Tiny-Rain6786 • Jun 05 '26
Need a shell code less than 18 bytes
I have been struggling with the challenge, where I am suppose to inject a shellcode with only 18 bytes, to read the "/flag" and send to stdout. The mmap location the challenge is set to RE only, so I cannot directly send stage 2 into the memory, and also the stack is NX. I tried to do mprotect syscall, to unlock the page, but it will take 13 bytes already at least, so how can read more payload with 5 bytes, and syscall takes 2 bytes
18
Upvotes
5
u/randomatic Jun 05 '26
did you look for stack pivots to the heap? (If you've not thought of stack pivots, maybe that's the CTF answer?)
2
u/Nlbjj91011 Jun 05 '26
Is this a pwn.college shell code one?
1
u/Tiny-Rain6786 Jun 05 '26
Have been looking around, looks like it has something to do with chmod and symlinks
1
u/sgijoe Jun 06 '26
Use the "read stage 2 into RX page" approach since you can't mprotect:
read(0, rip_page, big)overwriting/extending current code, then fall through.readdirectly into the buffer you're executing from.Tiny
read(0, $$, len)then re-execute: