Tags: pwn exploitation
Rating: 5.0
A NULL byte overwrite
If you input an invalid size while allocating the g_buf
,it would be record. But when you allocate successfully,the program will still append a NULL byte with the invalid size. So you can write a NULL byte on heap or libc.
_IO_buf_base
with null byte in the stdin structure
g_buf
_IO_flush_lockp
like house of orange.
_IO_write_ptr
> _IO_write_base
mode
<= 0vtable
point to the function that we want to call. (We want to call scanf
)stdin
structure
getchar()
to read data_chain
let point to g_buf_ptr
g_buf_ptr
so that we can't directly control it.g_buf_ptr
be _chain
pointer.
.got.plt
_IO_flush_all_lockp
exit
.
_IO_list_all
-> stderr
-> stdout
-> stdin
-> fake_fp
-> g_buf_ptr
scanf(g_buf_ptr)
scanf("%13$s%9$s")
%13$s
: Just read until stdin buffer is empty%9$s
: Read data to stack