House of Force

Posted countfatcode

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了House of Force相关的知识,希望对你有一定的参考价值。

原理:

House of Force是通过修改top chunksize从而通过分配内存达到任意地址写的目的。先看看glibc的源码:

      victim = av->top;   //取出top_chunk的地址
      size = chunksize (victim); //计算top_chunk的size

      if ((unsigned long) (size) >= (unsigned long) (nb + MINSIZE)) //此处nb为想要申请分配的堆的大小
        {
          remainder_size = size - nb;
          remainder = chunk_at_offset (victim, nb);  //获取分割后的top_chunk的地址
          av->top = remainder;
          set_head (victim, nb | PREV_INUSE |
                    (av != &main_arena ? NON_MAIN_ARENA : 0));
          set_head (remainder, remainder_size | PREV_INUSE);

          check_malloced_chunk (av, victim, nb);
          void *p = chunk2mem (victim);
          alloc_perturb (p, bytes);
          return p;
        }

 

以上是关于House of Force的主要内容,如果未能解决你的问题,请参考以下文章

hitcontraining_bamboobox 堆技巧 House of Force

6.house_of_spirit

8.house_of_lore

house of grey

溢出利用技巧house of spirit friendly stack overflow

House of XXX的核心原理