How to exploit printf
format string vulnurability on 64 bit system with NX enabled?
In this code example, what could you do to get a shell?
void f(char *buf) {
printf(buf);
exit(0);
}
int main() {
char buf[1024];
scanf("%1024s", buf);
f(buf);
return 0;
}
I think that because of NX and lack of obvious place to jump (there is no execve(/bin/bash...
anywhere in the code) it has to be a return-to-libc attack, but where to jump?
I belive it is possible to overwrite GOT entry of exit
to jump to arbitrary location, for example execve
or system
, but how to set proper arguments in registers? Search the binary for ROP chain and jump there?
Or is there some other way to get a shell out of this?