mirror of
https://github.com/nganhkhoa/CTF-All-In-One.git
synced 2024-12-25 11:41:16 +07:00
fix
This commit is contained in:
parent
f10dd97693
commit
f7a7d59428
@ -119,7 +119,7 @@ gef➤ x/8gx p3+(0x410/8)-2
|
||||
|
||||
然后依次释放掉 p1 和 p2,这两个 free chunk 将被放入 unsorted bin:
|
||||
|
||||
···text
|
||||
```text
|
||||
gef➤ x/8gx p1-2
|
||||
0x555555757000: 0x0000000000000000 0x0000000000000111 <-- p1 [be freed]
|
||||
0x555555757010: 0x00007ffff7dd3b78 0x0000555555757130
|
||||
@ -135,11 +135,11 @@ gef➤ heap bins unsorted
|
||||
[+] unsorted_bins[0]: fw=0x555555757130, bk=0x555555757000
|
||||
→ Chunk(addr=0x555555757140, size=0x410, flags=PREV_INUSE) → Chunk(addr=0x555555757010, size=0x110, flags=PREV_INUSE)
|
||||
[+] Found 2 chunks in unsorted bin.
|
||||
···
|
||||
```
|
||||
|
||||
接下来随便 malloc 一个 chunk,则 p1 被切分为两块,一块作为分配的 chunk 返回,剩下的一块继续留在 unsorted bin(p1 的作用就在这里,如果没有 p1,那么切分的将是 p2)。而 p2 则被整理回对应的 large bin 链表中:
|
||||
|
||||
···text
|
||||
```text
|
||||
gef➤ x/14gx p1-2
|
||||
0x555555757000: 0x0000000000000000 0x0000000000000041 <-- p1-1
|
||||
0x555555757010: 0x00007ffff7dd3c78 0x00007ffff7dd3c78
|
||||
@ -163,7 +163,7 @@ gef➤ heap bins large
|
||||
[+] large_bins[63]: fw=0x555555757130, bk=0x555555757130
|
||||
→ Chunk(addr=0x555555757140, size=0x410, flags=PREV_INUSE)
|
||||
[+] Found 1 chunks in 1 large non-empty bins.
|
||||
···
|
||||
```
|
||||
|
||||
整理的过程如下所示,需要注意的是 large bins 中 chunk 按 fd 指针的顺序从大到小排列,如果大小相同则按照最近使用顺序排列:
|
||||
|
||||
@ -224,13 +224,13 @@ gef➤ heap bins large
|
||||
|
||||
假设我们有一个漏洞,可以对 large bin 里的 chunk p2 进行修改,结合上面的整理过程,我们伪造 p2 如下:
|
||||
|
||||
···text
|
||||
```text
|
||||
gef➤ x/8gx p2-2
|
||||
0x555555757130: 0x0000000000000000 0x00000000000003f1 <-- fake p2 [be freed]
|
||||
0x555555757140: 0x0000000000000000 0x00007fffffffde60 <-- bk
|
||||
0x555555757150: 0x0000000000000000 0x00007fffffffde58 <-- bk_nextsize
|
||||
0x555555757160: 0x0000000000000000 0x0000000000000000
|
||||
···
|
||||
```
|
||||
|
||||
同样的,释放 p3,将其放入 unsorted bin,紧接着进行 malloc 操作,将 p3 整理回 large bin,这个过程中判断条件 `(unsigned long) (size) < (unsigned long) (bck->bk->size)` 为假,程序将进入 else 分支,其中 `fwd` 是 fake p2,`victim` 是 p3,接着 `bck` 被赋值为 (&stack_var1 - 2)。
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user