voidhello() { printf("code execution redirected! you win\n"); _exit(1); }
voidvuln() { char buffer[512];
fgets(buffer, sizeof(buffer), stdin);
printf(buffer);
exit(1); }
intmain(int argc, char **argv) { vuln(); }
Again, slight variation of the previous challenge, we have to write an arbitrary address somewhere in the stack. This time though, we have to redirect the execution flow. In order to do that we will replace the address of exit() by the address of hello().
Thanks to the hint, we can easily spot the right addresses :
We have to write 080484b4 at 08049724, our string is accessible at the 4th parameter of printf. I discovered that I could write 16 bit integers using the %hn modifier. This way I can write the desired address in two step.