House of Einherjar

House Of Einherjar 通过off-by-one/off-by-null, 申请任意地址 利用结果: 使malloc返回任意地址 要求: 堆泄露, off-by-null 适用版本: 本篇记录的是改进版的House of Einherjar, 适用于包括2.31的带tcache版本. 利用方式 总结一下, 会用到三个chunk: a,b,c a: 在其中构造fake chunk b: victim, 在其中off-by-null溢出到c, 并修改c的prev_size,与fake chunk重叠 c: 被溢出修改prev_size的chunk 一些细节如下: c的chunk大小应为0x100的倍数,这样off-by-null时就不会出问题 fake_chunk -> size 要等于 c-> prev_size fake_chunk -> fd, fake_chunk -> bk 都指向fake_chunk, 以绕过unlink时的检查,也因此需要堆泄露 流程: 申请a,b,c 在B中改写C->prev_size, 同时通过OFF-BY-NULL写C->prev_inuse为0 填满 tcache[c -> size]; 当然,情况允许的话,我们也可以直接申请大于tcache范围的chunk. 释放c, 触发fake_chunk与c的合并 申请fake_chunk+c的chunk, 叫他d 桥豆麻袋! 此处需要先malloc并free一个b大小的chunk做padding. 释放b 开始攻击(tcache poisoning): 利用d修改 b->fd 为target 申请两次,第二次申请获取到target! 参考 https://github.com/shellphish/how2heap/blob/master/glibc_2.31/house_of_einherjar.c

May 14, 2021 · 1 min · 69 words · N0k

House of Botcake

House of Botcake 2.27中也可使用, 绕过tcache double free的检测. 利用结果: 使malloc返回任意地址 要求: 存在double free 利用方式 使用0x100 (chunk size: 0x110)来演示: listTrash = malloc(0x100) * 7 prev = malloc(0x100) a = malloc(0x100) # the victim malloc (0x10) #padding free(listTrash[i]) for i in [0,7) # fill up tcachebin free(a) # free a; a in unsortedbin free(prev) # prev consolidate with a malloc(0x100); # get one chunk from tcache free(a) # free victim again, now it is also in tcachebin malloc(0x120) # 利用重叠申请到prev+victim合并产生的chunk 改写victim的fd malloc(0x100) # BOOM! 参考 https://github.com/shellphish/how2heap/blob/master/glibc_2.31/house_of_botcake.c ...

May 14, 2021 · 1 min · 83 words · N0k