> 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-vulnerabilities/api-attack/abus-dapi-pentesting-web.md).

# API-Missbrauch

## Webserver-Installation von GitHub (API-Missbrauch)

```bash
curl -o docker-compose.yml https://raw.githubusercontent.com/OWASP/crAPI/main/deploy/docker/docker-compose.yml
docker-compose pull
docker-compose -f docker-compose.yml --compatibility up -d

```

* Wir **registrieren** ein neuer Benutzer: ![](/files/2a28bb4946fb53b7ecb08014c5aa54a64d7e30a1)

## Aufklärung der API

* Um API-Schwachstellen zu finden, ist es wichtig, mit **guter Aufklärung**. Im Abschnitt Netzwerk erfassen Sie die Anfrage so wie Sie es mit [Burp Suite](/de/hacking-tools/web/burpsuite.md) unter Verwendung von XHR: ![](/files/8d356ae6820fad11ddc05edbc154eb29da1f1ed9)
* Um **strukturieren und speichern** alle API-Anfragen ordnungsgemäß, verwenden wir **Postman**:

```javascript
postman & disown &>/dev/null

```

* Erstellen Sie eine neue **Sammlung** in der alle API-Anfragen gruppiert werden. Für **POST** Anfragen fügen Sie die **URL** und insbesondere die rohe **Body**: ![](/files/7ed8d030ab8de6c66553cb4cd28ef657b92bd85f) ![](/files/3a5bf789cebb5610ba1316b40492d45a5de172aa)
* Es gibt das **Token mit der Struktur JWT** des Logins zurück: ![](/files/b90ba453350189d661d42e1381ee59eb3b47e15e)
* Erstellen Sie eine Variable mit dem Namen **accessToken** mit dem Wert des Login-Tokens: ![](/files/e386478bee44494bbd92eae194da6b7626325eec)
* Im Abschnitt **Autorisierung**, ordnen Sie die Variable dem Typ **Bearer Token**: ![](/files/1a9d101bb7c71eb5e4cbbd67dff27c8fef749e93)
* Speichern Sie alle **möglichen Anfragen**:

1. Dashboard: ![](/files/9c22f37cc0c4a0f4b1a1e0fa9c19691bc32070c0)
2. Produkte: ![](/files/d911c32da463cbf4a28ea95b8fd6e9bcdf02dfc2)
3. Befehl: ![](/files/291c083242c7166317ea5132157fd03c1e108729)

## Schwachstellen im Zusammenhang mit API-Missbrauch:

### Brute-Force-Token-Wiederherstellung:

Es gibt eine Option zum **Zurücksetzen des Passworts** durch Abrufen eines Tokens per E-Mail:

<figure><img src="/files/95562719b43db3291d2c4215cf73bc7db7cf0c79" alt="" width="563"><figcaption></figcaption></figure>

Auf Port *8025*, gibt es eine **SMTP** in der wir das Token erhalten:

<figure><img src="/files/1737233f3a6d5f5c6fdee208cfd91464794d60c3" alt="" width="563"><figcaption></figcaption></figure>

Klicken **Passwort vergessen** mit der E-Mail-Adresse des Kontos, dessen Passwort Sie ändern möchten:

<figure><img src="/files/bd48610aad6853c5e95e24368b3987b529a4a5e9" alt="" width="563"><figcaption></figcaption></figure>

Wir erfassen die **query** an die API:

<figure><img src="/files/8fe4646ed142058620bc242b29d98f24c98d69f0" alt="" width="563"><figcaption></figcaption></figure>

Wir senden die Anfrage als **POST** mit der Rohstruktur:

<figure><img src="/files/362e03b645097b639b26ef78f0178ef2c683e304" alt="" width="563"><figcaption></figcaption></figure>

Wir verwenden **ffuf** um einen **Brute-Force-Angriff**:

```graphql
ffuf -u http://localhost:8888/identity/api/auth/v2/check-otp -w /usr/share/SecLists/Fuzzing/4-digits-0000-9999.txt -X POST -d '{"email":"jordan@jordan.com","otp":"FUZZ","password":"Password1234*"}' -H "Content-Type: application/json" -p 1 -mc 200

```

Das **Bestätigungstoken** 0172 gab einen **erfolgreichen Statuscode zurück** und das Passwort wurde automatisch geändert:

<figure><img src="/files/1cda619d1c2a0d6b513a2c7a4381d0164e784d22" alt="" width="563"><figcaption></figcaption></figure>

### Produktpreise ändern und den verfügbaren Kontostand erhöhen:

Wir suchen mit **ffuf** der möglichen Methode der Anfrage **products**:

```bash
ffuf -u http://localhost:8888/workshop/api/shop/products -w /usr/share/SecLists/Fuzzing/http-query-methods.txt -X FUZZ -p 1 -mc 200,401

```

Dies sind alle **möglichen Methoden**:

<figure><img src="/files/94072d51eaad71e38aea31a241c0d16366e350bd" alt="" width="563"><figcaption></figcaption></figure>

Wenn wir von **GET** zu **POST**, geschieht Folgendes:

<figure><img src="/files/3ef9d6783637f8d456c446b40d031196e59393c7" alt="" width="563"><figcaption></figcaption></figure>

Dies ist eine **Mass Assignment** Schwachstelle, die die Erstellung von Produkten durch **POST** Anfragen ermöglicht. In diesem Fall erstellen wir ein Produkt mit einem **negativen** Preis:

<figure><img src="/files/f03c4a51abec7d838f88001e733c91b7b582d7cd" alt="" width="563"><figcaption></figcaption></figure>

Auf diese Weise wird es **interpretiert** vom Webserver:

<figure><img src="/files/7f313c5b9054fe4234fb09a2b45d1729062f95cd" alt="" width="563"><figcaption></figcaption></figure>

Da der Preis **negativen**, wird jedes Mal, wenn wir auf **kaufen**, 10.000 Dollar zu unserem Kontostand hinzugefügt:

<figure><img src="/files/af9ec01a7072ab7deb98f92a103b4012908bea4e" alt="" width="563"><figcaption></figcaption></figure>

Wenn in der Anfrage **Bestellungen**, wir die Nummer des Produkts einfügen, zum Beispiel mit einer Menge von 100, wird unser Kontostand mit **100 x 10.000**:

<figure><img src="/files/60ac59e498e11083bba07605fdf2eafc25f09a13" alt="" width="563"><figcaption></figcaption></figure>

### Einen gültigen Gutscheincode finden:

Wir senden die Anfrage von **validate-coupon**:

<figure><img src="/files/44039991e914df508d5e6ac0b330d4118acbfcfc" alt="" width="563"><figcaption></figcaption></figure>

Da der Gutschein **nicht korrekt**, gibt der Server nichts zurück:

<figure><img src="/files/5d8485577330bc6045829b2c428681555b69488a" alt="" width="524"><figcaption></figcaption></figure>

Wenn wir versuchen, eine Injektion auszuführen [NoSQL ](/de/web-vulnerabilities/nosql-attack.md)weil die Datenbank **MongoDB**, antwortet sie mit dem Gutscheincode:

<figure><img src="/files/893eca3f292b0d98d768bcbfb8ae51d822435637" alt="" width="563"><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-vulnerabilities/api-attack/abus-dapi-pentesting-web.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.
