48 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# House of Lore | Small bin Attack
{{#include ../../banners/hacktricks-training.md}}
## 基本信息
### 代码
- 检查来自 [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/)
- 这不起作用
- 或者: [https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c](https://github.com/shellphish/how2heap/blob/master/glibc_2.39/house_of_lore.c)
- 即使它尝试绕过一些检查,仍然不起作用,出现错误: `malloc(): unaligned tcache chunk detected`
- 这个例子仍然有效: [**https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html**](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html)
### 目标
- 在小桶中插入一个**假小块,以便可以分配它**。\
注意,添加的小块是攻击者创建的假块,而不是任意位置的假块。
### 要求
- 创建2个假块并将它们链接在一起并与小桶中的合法块链接:
- `fake0.bk` -> `fake1`
- `fake1.fd` -> `fake0`
- `fake0.fd` -> `legit`(您需要通过其他漏洞修改已释放小桶块中的指针)
- `legit.bk` -> `fake0`
然后您将能够分配`fake0`
### 攻击
- 分配一个小块(`legit`),然后分配另一个小块以防止与顶部块合并。然后,释放`legit`(将其移动到未排序的桶列表中),并分配一个更大的块,**将`legit`移动到小桶中。**
- 攻击者生成一对假小块,并进行必要的链接以绕过完整性检查:
- `fake0.bk` -> `fake1`
- `fake1.fd` -> `fake0`
- `fake0.fd` -> `legit`(您需要通过其他漏洞修改已释放小桶块中的指针)
- `legit.bk` -> `fake0`
- 分配一个小块以获取合法块,使**`fake0`**成为小桶的顶部列表
- 再分配一个小块,获取`fake0`作为块,允许潜在地读取/写入其中的指针。
## 参考
- [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_lore/)
- [https://heap-exploitation.dhavalkapil.com/attacks/house_of_lore](https://heap-exploitation.dhavalkapil.com/attacks/house_of_lore)
- [https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html](https://guyinatuxedo.github.io/40-house_of_lore/house_lore_exp/index.html)
{{#include ../../banners/hacktricks-training.md}}