美文网首页
glibc2.31 how2heap

glibc2.31 how2heap

作者: clive0x | 来源:发表于2021-01-28 11:41 被阅读0次

堆溢出去年花了一个月业余时间,看得一知半解,今年又花了两个月业余时间才弄清楚,比较复杂。

https://github.com/shellphish/how2heap/blob/master/glibc_2.31/unsafe_unlink.c

printf("We setup the 'next_free_chunk' (fd) of our fake chunk to point near to &chunk0_ptr so that P->fd->bk = P.\n");

chunk0_ptr[2] = (uint64_t) &chunk0_ptr-(sizeof(uint64_t)*3);

printf("We setup the 'previous_free_chunk' (bk) of our fake chunk to point near to &chunk0_ptr so that P->bk->fd = P.\n");

printf("With this setup we can pass this check: (P->fd->bk != P || P->bk->fd != P) == False\n");

chunk0_ptr[3] = (uint64_t) &chunk0_ptr-(sizeof(uint64_t)*2);

这两段比较难懂,直接上图

chunk0_ptr做fake_chunk

chunk0_ptr[1]为fake_chunk size字段

chunk0_ptr[2]为fake_chunk fd字段

chunk0_ptr[3]为fake_chunk bk字段

要理解下面两句话:

chunk0_ptr[2] = (uint64_t) &chunk0_ptr-(sizeof(uint64_t)*3)

chunk0_ptr[3] = (uint64_t) &chunk0_ptr-(sizeof(uint64_t)*2);

须了解unlink原理:fake_chunk->fd->bk=fake_chunk

fake_chunk->bk->fd=fake_chunk

chunk0_ptr[2] 指向fd,要使得fake_chunk->fd->bk=fake_chunk条件满足

fake_chunk->fd要整体看,当成另外一个chunk,其chunk address须为&fake_chunk-3,->bk为3个指针偏移,即可满足。

tcache 最多有64个bins(类hash slots),每个bin是多7个chunks

chunksizes from 24 to 1032 (12 to 516 on x86) bytes, in 16 (8 on x86) byte increments

相关文章

  • glibc2.31 how2heap

    堆溢出去年花了一个月业余时间,看得一知半解,今年又花了两个月业余时间才弄清楚,比较复杂。 https://gith...

  • mmap overlapping chunks

    https://github.com/shellphish/how2heap/blob/master/glibc_...

  • tcache house of spirit

    https://github.com/shellphish/how2heap/blob/master/glibc_...

  • overlapping chunks

    https://github.com/shellphish/how2heap/blob/master/glibc_...

  • poison null byte

    https://github.com/shellphish/how2heap/blob/master/glibc_...

  • house of lore

    在glibc2.31上已经失效。没有考虑tcache开启,属于较老的一种利用。 1.在栈在构造目标chunk 1和...

  • unlink attack --how2heap unlink

    unlink 简介 unlink用于将 chunk 从所在的空闲链表中取出来。基本过程如下: 执行unlink时的...

网友评论

      本文标题:glibc2.31 how2heap

      本文链接:https://www.haomeiwen.com/subject/osuttltx.html