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

# RCE por deserialización en PHP

## Deserialización (PHP)

Encontramos un sitio web donde puedes **enviar pings**:

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

Probamos **probar diferentes entradas**, pero nada funcionó:

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

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

Enviamos un ping a nuestra **propia dirección IP del atacante** e interceptamos la solicitud con [Burp](/es/hacking-tools/web/burpsuite.md):

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

Vemos que está **serializado**:

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

El **PHP** el código al que nos enfrentamos es similar al siguiente:

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

Después de analizar el código, observamos que al cambiar **$isValid** a `true` e inyectar una shell inversa en **ipAddress** después de un **;** debería desencadenar la ejecución de comandos:

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

Luego, nosotros **serializamos** el archivo de nuevo con **PHP**:

<figure><img src="/files/6124ddc42a90e5b065ceaaaf30cf23b420834fa4" alt=""><figcaption></figcaption></figure>

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

Con **Netcat**, escuchamos en el puerto **443** y recibimos la shell:

<figure><img src="/files/a6f8d68ce482a0cd7c2370a36349233db7c1ed94" 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/es/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.
