My friend keeps writing super insecure C programs but I’m too lazy to fix his code. I’m sure it’ll be fine as long as I use enough exploit mitigations, right? nc lac.tf 31180
[70 solves / 462 points]
Analysis
1 2 3 4 5
Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled
Full Relro!! NX and PIE are enabled.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include<stdio.h>
intmain(void) { setbuf(stdout, NULL); puts("What would you like to post?"); char buf[512]; fgets(buf, 512, stdin); printf("Here's your latest post:\n"); printf(buf); printf("\nWhat would you like to post?\n"); fgets(buf, 512, stdin); printf(buf); printf("\nYour free trial has expired. Bye!\n"); return0; }
You can find twice fsb.
Solve
leak libc, stack, pie / ret2main (Overwrite the ret in stack to main)
Overwrite the ret in stack to system / Overwrite the rdi to ‘/bin/sh\x00’
The rdi is in the writeable space. You know the libc address. Got the offset during debugging and overwrite it.