Description 1
Description 1
Description 1
Chall
Description
The obligatory format string challenge comes back, but with a twist.
Me personally think this challenge is the easiest among the pwn category, because
we don't really need a script to solve it, but yeah we have to know the trick, this
challenge vuln was format string (actually one of my favourite pwn challenge
because easy and fun).
Disassembly :
void main(void)
{
size_t sVar1;
long in_FS_OFFSET;
char *local_28;
char **local_20;
FILE *local_18;
undefined8 local_10;
Exploit
How our stack looks like after the printf :
So, the idea is overwrite the stack address that point to heap with just one byte,
this one so the stack address will point to our heap that contain flag.
The payload is :
%c%c%c%c%c%155c%hhn%6$s
we stack up %cuntil we hit the 6th stack, the 7th format will be the payload to
overwrite one byte %hhn this will overwrite 7th stack one byte, 155 is a padding,
we want to overwrite the heap to 0xa0 in the end(0xa0 is 160) but since we already
have 5 %c earlier we have to substract it with 5, and with that the overwrite will
be saved, so when we do %6$s this will actually going to treat the 6th stack as
string and actually leak out our flag.
note : stack i provided earlier is stack after printf and stack i talked about is
when we do %p since some of the earlier stack is something