> 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/authentication/username-enumeration-via-response-timing.md).

# 通过响应时间进行用户名枚举

通过响应时间进行用户名枚举，PortSwigger Web Security Academy 实验笔记，包括利用流程、载荷测试、Burp Suite 验证以及修复上下文。

### 通过响应时间进行用户名枚举

这个实验室存在基于响应时间的用户名枚举漏洞。要解决它，你需要识别出一个有效用户名，对你的密码进行原始暴力破解攻击，然后访问你的账户页面。

```bash
你的凭据：wiener:peter
```

### **初步分析**

当测试大量密码时，应用程序会显示一条错误消息，指出检测到了过多尝试。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-18e4eee134747be67f320dc7e8362dc65968a908%2F%7B94C85D5E-85D5-4FD4-A779-8BCC8351A49E%7D.png?alt=media" alt="" width="477"><figcaption></figcaption></figure>

为绕过此保护，添加以下请求头：

```bash
X-Forwarded-For: 127.0.0.2
```

### **响应时间测量**

发送一个带有极长 **密码** 针对用户 `wiener`:

{% code overflow="wrap" %}

```bash
username=wiener&password=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
```

{% endcode %}

然后可以观察到该响应大约需要 **3 秒** 才返回。

另一方面，如果使用无效用户名\*\*发送同样的请求，响应则是 **几乎瞬时**:

```bash
username=dwdwd&password=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
```

因此，这种差异使得可以区分有效 **用户名** 和无效用户。

#### **使用 Intruder 生成列表**

在 Intruder 中，我们使用 **Pitchfork** 技术。

* 第一个位置： **待测试用户名列表** 要测试

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-197dcb9591365ae17191442c5a8886be433599ac%2F%7B6B917060-177C-43FB-BC6C-A9A265F7CEFA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

第二个位置： **不同的 IP 地址列表** 发送到 `X-Forwarded-For`

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d04b41d186f46f44b1b240c2812a9c6587bb362f%2F%7B4501EB8A-7BA4-4D12-A530-6A2BCF8616AF%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-bb65673524388490f1db31021b3246baa6780b5a%2F%7B0E72DC9F-1194-4CC3-BE7B-27566B70ACC9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

该字段 **响应完成** 被分析：

与有效用户关联的响应耗时显著更高（Apache 显示的值大得多）。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c15e53d3534008714c11158246a43fbb571d8cc5%2F%7B863369CA-5117-4A5C-8AE6-F62933497E92%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-4748af9aab774dc58ed5e790387038593c0c6afb%2F%7BC272F45E-E8D1-463F-9DD9-995AB7B1B41C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们注意到，密码为 **chelsea** 的尝试会产生不同的响应：一个 **302 Found**，这表明身份验证成功。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aaa7587356864b4fb30b590ba5c9c9a4b5027b5b%2F%7B122670AB-B019-411C-BF83-2B4DA65EB3EF%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-e6e8b8d15f2bf424b2259fea3884765f23561860%2F%7B815C9DA3-77D7-4CCE-8B13-27F346874840%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/authentication/username-enumeration-via-response-timing.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.
