본문으로 바로가기

[Heap] fastbin dup consolidate

category System Hacking ( pwnable )/ETC 2019. 8. 1. 16:52

1. fast chunk 2개 할당


2. 첫번째 fast chunk를 free


3. large bin size의 chunk 하나 할당

-malloc_consolidate()함수가 trigger되고, (2)번에서 free한게 unsorted bin으로 감.

-즉, (2)번에서 free한걸 한번 더 free해도 fastbin의 보호기법이 작동하지 않음.

-fast-top에서 unsorted bin으로 갔기 때문.


4. (2)번에서 free했던 chunk 한번 더 free (DFB)


5. 다음 두번의 malloc은 (2)번에서 free한 주소와 같음.

-unsorted bin에서 한번, fast bin에서 한번 꺼내서 총 두번까지 꺼내올 수 있음


1
2
3
4
5
6
7
8
9
10
11
12
13
first = malloc(0x30// malloc two fast chunk 
second = malloc(0x30)
 
free(first) // fast bin
 
third = malloc(0x100// malloc one small chunk
                      // now, first in unsorted bin
free(first) // Double Free Bug!!
 
fourth = malloc(0x30// address first
fifth = malloc(0x30// address first
 
 
cs