How to pwn a printf
fgets(hello, 256, stdin);
printf(hello);
fgets(hello, 256, stdin);
printf(hello);
NOPE
fn(){ int a = 42; char* b = "Hello world"; printf("%s and %x", b, a); }
Expected result:
"Hello world and 42"
void fn(char* input){ int password = 0x12345678; printf(input); }
Given input = "%x\n%x\n%x"
Expected output:
<top_secret>
<fn's ebp>
<fn's return>
void fn(){ char buffer[1024]; gets(buffer); printf(buffer); }
Buffer = "\x12\x34\x56\x78 %3$s"
Print string located at 0x78563412