您的位置:首页 > 其它

hitcon 2017 ghost in the heap解题记录

2018-03-08 19:03 411 查看

ghost in the heap

审计

delete heap

free后会将ghost[i]置null,所以不能double free

add ghost

要求填入magic,但是会被read冲掉

read长度小于最大限长

add heap

使用了scanf,可能使用file struct

scanf限制了输入长度,无法直接溢出堆

泄露libc和heap

让ghost trunk连接到unsortedbin,再释放一个unsorted bin 如果不发生合并,必然会更新unsortedbin链(ghost trunk包含泄露的Libc和heap),再次malloc时,ghost chunk size < unsortedbin trunk size大小,malloc会把ghostchunk调整到smalltrunk,发现满足0x60 size,

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main()
{
char* p1,*p2,*p3,*ptr;
ptr=malloc(0x50);
p1=malloc(0xa0);
p2=malloc(0xa0);
p3=malloc(0xa0);
free(ptr);
free(p1);
free(p3);
p1=malloc(0xa0);//unsortedbin指向一个size只有0x60的段
p3=malloc(0xa0);//malloc调整该trunk进入smalltrunk
free(p2);
p2=malloc(0xa0);
free(p1);
ptr=malloc(0x50);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: