> 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/api-testing/operating-an-endpoint-using-documentation.md).

# 使用文档操作端点

使用文档操作端点利用端点的笔记，适用于 PortSwigger Web Security Academy 实验室，包括利用流程、载荷测试、Burp Suite 验证和修复

### 利用文档中的 API 端点

**实验目标**

本实验的目标是找到暴露的 API 文档，然后使用某个端点删除该用户 **carlos**. / 提供了一个有效账户用于测试：

* **凭据**: `wiener:peter`

**API 文档的发现**

探索应用程序后发现一条路由，指向一个 **REST API** ，其中包含其文档。/ 该文档清楚地描述了可用的端点，甚至提供了可直接使用的请求示例，包括以 **curl** 命令的形式。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-25a299a5a6ef0216e1435f685ef8f6b45855e8f6%2F%7BF84034CF-B750-45B1-B1A0-18404C268350%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**获取用户信息**

从文档中可以看出，某个端点允许用户通过指定其姓名来检索信息。/ 所提供的请求返回用户数据 **carlos**:

* 请求：
* 方法： `GET`
* 端点： `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X GET 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos'
```

{% endcode %}

* 答案：
* 服务器返回一个包含用户名和电子邮件地址的 JSON 对象。

```json
{
  "username": "carlos",
  "email": "carlos@carlos-montoya.net"
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d0a4b077ed12f06d1d52c3d3145d18a8a75daf67%2F%7B1AE03A8E-62A8-443F-9A51-3464E49D9F5F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**删除 carlos 用户**

文档还表明，可以通过专用请求删除用户。/ 使用相应的端点并采用适当的方法：

* 请求：
* 方法： `DELETE`
* 端点： `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X DELETE 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos' -d '{}'
```

{% endcode %}

* 结果：
* 服务器接受该请求并返回一条确认用户已被移除的消息。

```json
{
  "status": "User deleted"
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-efbdc4dd51179a013837c9c3cfe3e0d58b809ac6%2F%7BC1A96813-127E-4F44-A97C-F592F1E7B7CD%7D.png?alt=media" 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 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/api-testing/operating-an-endpoint-using-documentation.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.
