> 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/web-vulnerabilities/deserialization-attack/php-deserialization-rce-pentesting-web.md).

# RCE por desserialização PHP

## Desserialização (PHP)

Encontramos um site onde você pode **enviar pings**:

<figure><img src="/files/475483592ad58adae7f6b1b5061fb715675e145a" alt="" width="563"><figcaption></figcaption></figure>

Tentamos **testando diferentes entradas**, mas nada funcionou:

<figure><img src="/files/93be95e2fc9a3b9fa20471a2923e32cce3887cf6" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/4bdc94801f654fd9ea06492343c0ee072b80aaf8" alt="" width="530"><figcaption></figcaption></figure>

Enviamos um ping para o nosso **próprio endereço IP do atacante** e interceptamos a requisição com [Burp](/pt-br/hacking-tools/web/burpsuite.md):

<figure><img src="/files/f1d9fa5ae94bfee01054d1955fa5b1170eff680a" alt="" width="563"><figcaption></figcaption></figure>

Vemos que ele está **serializado**:

<figure><img src="/files/7b0838022ce4d4f129995686b80ec5731232210b" alt="" width="563"><figcaption></figcaption></figure>

O **PHP** o código com o qual estamos lidando é semelhante ao seguinte:

<figure><img src="/files/28e3450f8db400f836663c684d39c04dbc5c9b51" alt="" width="563"><figcaption></figcaption></figure>

Após analisar o código, observamos que alterar **$isValid** para `true` e injetar uma shell reversa em **ipAddress** após um **;** deve acionar a execução de comandos:

<figure><img src="/files/6a5e45d75f407f8eb1f09afe78f798d2963162a2" alt="" width="563"><figcaption></figcaption></figure>

Então, nós **serializamos** o arquivo novamente com **PHP**:

<figure><img src="/files/33a499c40f38d89a1a57dec7a2b8546ac904d356" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/209c17b98a9e71175858ad588d1144615883b6c3" alt="" width="563"><figcaption></figcaption></figure>

Com **Netcat**, ouvimos na porta **443** e recebemos a shell:

<figure><img src="/files/80162bcb273049256de2527b883c22dd24a1b574" 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/web-vulnerabilities/deserialization-attack/php-deserialization-rce-pentesting-web.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.
