> 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/authentication/2fa-bypass-via-brute-force.md).

# 2FA-Umgehung per Brute-Force

### 2FA-Bypass mithilfe eines Brute-Force-Angriffs

Dieses Labor hat zwei Faktoren, die anfällig für Brute-Force-Angriffe sind. / Benutzer-IDs sind bereits bekannt, aber der 2FA-Verifizierungscode ist nicht zugänglich. / Das Ziel ist es, den MFA-Code zu erzwingen, um auf das Konto von **Carlos**.

* **Opfer**: `carlos`
* **Passwort**: `montoya`

<figure><img src="/files/8407cd38d819521908eedfaa67ba3c8c052f2586" alt=""><figcaption></figcaption></figure>

**2FA-Authentifizierungskontext**

Nach einer erfolgreichen Anmeldung mit Benutzername und Passwort verlangt die Anwendung einen MFA-Code.

Die serverseitige Abfrage sieht so aus:

```bash
csrf=pqkmb1Cny2T3wbbgKEdqZPweWFpyCv0A&mfa-code=1234
```

**Problem festgestellt**

* Beim Testen mehrerer MFA-Codes zeigt der Server an, dass das **CSRF-Token nicht mehr gültig ist**.

<figure><img src="/files/fafb99289c184b9cbb68b41e16be56e671a000e4" alt="" width="464"><figcaption></figcaption></figure>

* Die Anwendung leitet dann automatisch zur Anmeldeseite weiter.

Bei jedem neuen Zugriff auf die Anmeldeseite wird ein **neues CSRF-Token** generiert.

Dies verhindert einen direkten Brute-Force-Angriff auf den `mfa-code` Parameter auszunutzen.

<figure><img src="/files/9c30ef393950d83e3f5109781db031028e742459" alt=""><figcaption></figcaption></figure>

**Einrichtung der Lösung (Burp Suite)**

Um diese Schutzmaßnahme zu umgehen, wird ein **Makro** verwendet, um bei jedem Versuch automatisch ein gültiges CSRF-Token neu zu generieren.

<figure><img src="/files/54e5450b8f2dfd05cf51cc7f95e6f4ceee8aff22" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/4d3efe1d797c95053e336341a504350ca314e813" alt="" width="461"><figcaption></figcaption></figure>

**Schritte:**

1. Erstellen Sie eine neue **Makro** in Burp Suite.

<figure><img src="/files/bb07cc75fb6d02a38e1ccb52f097bd6041b6efec" alt="" width="459"><figcaption></figcaption></figure>

* Fügen Sie die folgenden Anfragen in das Makro ein:
* `GET /login`
* `POST /login`
* `GET /login2`

<figure><img src="/files/8ede30454b8f568a43731731ec1f0a5c6668d715" alt=""><figcaption></figcaption></figure>

1. Überprüfen Sie, dass das Makro das Extrahieren eines **neues CSRF-Token** bei jeder Ausführung ermöglicht.

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

Das Makro ist nun bereit und funktionsfähig.

**Brute-Force-Angriff auf den MFA-Code**

1. Interceptieren Sie die `POST` Abfrage, die den `mfa-code` Parameter auszunutzen.

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

* Senden Sie diese Anfrage an **Intruder**.
* Setzen Sie die Nutzlast im `mfa-code` Feld.
* Setzen Sie einen Wertebereich von **0000 bis 9999**, mit einem Format von **4 erforderlichen Ziffern**.

<figure><img src="/files/a47520464055f70651a2242a03732b950ad2a86c" alt="" width="394"><figcaption></figcaption></figure>

Verknüpfen Sie das Makro so, dass **das CSRF automatisch aktualisiert wird** bei jeder Anfrage.

<figure><img src="/files/4123d721c9bd6b55cb0927d29641e733aada7cf6" alt=""><figcaption></figcaption></figure>

**Ergebnis**

* Das CSRF-Token ändert sich bei jedem Versuch korrekt.
* Wenn ein gültiger MFA-Code getestet wird, unterscheidet sich die Serverantwort.
* Der richtige Code ist anhand einer **`302 Found`** Antwort erkennbar, die auf eine erfolgreiche Weiterleitung zum Benutzerkonto hinweist.

<figure><img src="/files/b3ebac52abd266a694e577b260fd00c452e040ef" 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/authentication/2fa-bypass-via-brute-force.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.
