From the Start
Binary Exploitation
My blog has migrated to https://wintertia.pages.dev/ ! This Gitbook will no longer be maintained.
This challenge was nice enough to give source code!
#include <stdio.h>
__attribute__((constructor)) void init(){
setbuf(stdin, NULL);
setbuf(stdout, NULL);
}
__attribute__((naked)) void helper(){
__asm__(
"pop %rdi\nret\n"
"pop %rsi\nret\n"
"pop %rdx\nret\n"
);
}
int main(){
init();
char mem[0x100];
puts("pwning from the start okay?");
gets(mem);
return 0;
}No protections all over, given free gadgets, and in the dist we are also given the Dockerfile so I could easily just grab the libc, this makes a ret2libc attack way easier to do.
The plan is now as follows:
Buffer overflow using insecure
getsand take over RIPLeak libc somehow
Ret2libc
RIP offset was found at 264 bytes, so now the next thing to do is to leak libc. Given the GOT Entry for puts, I can easily leak it to find offset of libc.
After that, just hook everything up to a classic ret2libc payload and get flag! This image below is using local solve:

Here is the full script:
Last updated