> 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/host-header/bypassing-validation-by-connection-state.md).

# 通过连接状态绕过验证

### 通过连接状态攻击绕过主机验证

**漏洞描述**

这个实验有一个 **基于通过 Host 路由的 SSRF 类型漏洞** 头部，这与服务器端连接状态管理不善有关。

尽管前端服务器似乎正确验证了 `Host` 头部，但它做出了一个危险的\*\*假设\*\*：

> 如果 **第一条请求** 是有效的。

这使得可以在同一连接中注入后续的恶意请求，从而绕过最初的验证。

**实验目标**

* 访问内部管理面板:/ `HTTP://192.168.0.1/admin`
* 删除用户 **carlos**

**初步观察**

对内部 IP 的直接请求被阻止：

```http
GET / HTTP/1.1
Host: 192.168.0.1
```

服务器拒绝了该请求，这证实了 `Host` 已实施验证 **在第一条请求时**.

<figure><img src="/files/7921c6aed5ed9b2cdf456bf5bf389810073159cc" alt=""><figcaption></figcaption></figure>

**操作：连接状态攻击**

思路是在同一个 TCP 连接上发送\*\*多个请求\*\*：

1. 向公共主机发送一个合法的第一请求（被接受）。
2. 发送到内部 IP 的第二个恶意请求， **在同一连接上**.

<figure><img src="/files/1bf85557594d55e998718adf152617bfc47ef18f" alt=""><figcaption></figcaption></figure>

在 Burp Suite 中，这是通过以下方式完成的：

* 将请求分组
* 使用 **在单个连接中发送组**

<figure><img src="/files/314d14058225845780063970112b8d0ec3be3e86" alt=""><figcaption></figcaption></figure>

**访问管理面板**

一旦使用有效请求建立连接，随后对内部管理端的请求就会被接受：

```http
GET /admin HTTP/1.1
Host: 192.168.0.1
```

这样就可以访问内部管理面板。

<figure><img src="/files/48a12bec669c858f0562fb8add59167ca5ac65b5" alt=""><figcaption></figcaption></figure>

**删除用户**

删除该用户需要一个 POST 请求：

```http
POST /admin/delete HTTP/1.1
Host: 192.168.0.1

csrf=ppBVKn8wVrgZifEETHsn48Hykwiq8yFO&username=carlos
```

服务器响应：

<figure><img src="/files/7aeafb648a24c23bdcdf18904214fa6ceb7c6ba3" alt="" width="446"><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/host-header/bypassing-validation-by-connection-state.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.
