hacktricks/binary-exploitation/libc-heap/house-of-lore.md

74 lines
4.6 KiB
Markdown
Raw Normal View History

2024-06-13 15:08:26 +00:00
# House of Lore | Small bin Attack
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
{% hint style="success" %}
2024-07-18 16:14:56 +00:00
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
<details>
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
<summary>Support HackTricks</summary>
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
2024-05-14 11:10:13 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
2024-07-18 16:04:36 +00:00
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2024-05-14 11:10:13 +00:00
</details>
2024-07-18 16:04:36 +00:00
{% endhint %}
2024-05-14 11:10:13 +00:00
## Basic Information
### Code
* Check the one from [https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house\_of\_lore/](https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house\_of\_lore/)
2024-05-17 15:37:03 +00:00
* This isn't working
2024-05-14 11:10:13 +00:00
* Or: [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)
2024-06-13 15:08:26 +00:00
* This isn't working even if it tries to bypass some checks getting the error: `malloc(): unaligned tcache chunk detected`
2024-07-11 13:10:36 +00:00
* This example is still working: [**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)&#x20;
2024-05-14 11:10:13 +00:00
### Goal
2024-06-13 15:08:26 +00:00
* Insert a **fake small chunk in the small bin so then it's possible to allocate it**.\
2024-07-11 13:10:36 +00:00
Note that the small chunk added is the fake one the attacker creates and not a fake one in an arbitrary position.
2024-05-14 11:10:13 +00:00
### Requirements
2024-07-11 13:10:36 +00:00
* Create 2 fake chunks and link them together and with the legit chunk in the small bin:
2024-06-13 15:08:26 +00:00
* `fake0.bk` -> `fake1`
* `fake1.fd` -> `fake0`
* `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln)
* `legit.bk` -> `fake0`
2024-07-11 13:10:36 +00:00
Then you will be able to allocate `fake0`.
2024-05-14 11:10:13 +00:00
### Attack
2024-07-11 13:10:36 +00:00
* A small chunk (`legit`) is allocated, then another one is allocated to prevent consolidating with top chunk. Then, `legit` is freed (moving it to the unsorted bin list) and the a larger chunk is allocated, **moving `legit` it to the small bin.**
* An attacker generates a couple of fake small chunks, and makes the needed linking to bypass sanity checks:
2024-06-13 15:08:26 +00:00
* `fake0.bk` -> `fake1`
* `fake1.fd` -> `fake0`
* `fake0.fd` -> `legit` (you need to modify a pointer in the freed small bin chunk via some other vuln)
* `legit.bk` -> `fake0`
* A small chunk is allocated to get legit, making **`fake0`** into the top list of small bins
2024-07-11 13:10:36 +00:00
* Another small chunk is allocated, getting `fake0` as a chunk, allowing potentially to read/write pointers inside of it.
2024-05-14 11:10:13 +00:00
## References
* [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)
2024-06-13 15:08:26 +00:00
* [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)
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
{% hint style="success" %}
2024-07-18 16:14:56 +00:00
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
<details>
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
<summary>Support HackTricks</summary>
2024-05-14 11:10:13 +00:00
2024-07-18 16:04:36 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
2024-05-14 11:10:13 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
2024-07-18 16:04:36 +00:00
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2024-05-14 11:10:13 +00:00
</details>
2024-07-18 16:04:36 +00:00
{% endhint %}