> 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

Notizen zur 2FA-Umgehung per Brute Force für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### Umgehung der 2FA mithilfe eines Brute-Force-Angriffs

Dieses Labor verfügt über zwei Faktoren, die anfällig für Brute-Force-Angriffe sind. / Die 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3834412bbcf44d707207510096f72ba0b0eccada%2F%7B4DED2AEE-EA63-4072-9E04-BAF3CFC206DC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**2FA-Authentifizierungskontext**

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

Die serverseitige Anfrage sieht folgendermaßen aus:

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

**Problem aufgetreten**

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-964d0e1a2d6d3bd6103dc107200e6915e9773250%2F%7BC01D1654-0FBB-418B-9281-E7AE950854A1%7D.png?alt=media" alt="" width="464"><figcaption></figcaption></figure>

* Die Anwendung leitet dann automatisch zur Anmeldeseite weiter.

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

Dies verhindert einen direkten Brute-Force-Angriff auf das `MFA-Code` Parameter angeben.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7201e3354f2bd7840af1ba91304b8ddd869057b6%2F%7BAA71B106-2316-4CD6-ADDA-6F8FA67512DD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

Um diesen Schutz zu umgehen, wird ein **Makro** verwendet, um bei jedem Versuch automatisch einen gültigen CSRF-Token neu zu erzeugen.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-89547f86ba355f76c71e4433af94aa50d6ea96e1%2F%7BCC2731F5-E07D-487D-8B38-81D8336FEA6B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1e764a2d92dac7dde3dd174cf8b5dcdc87e39fab%2F%7B3EF5EB33-F316-4FF5-AFDA-E9FEFFC38E36%7D.png?alt=media" alt="" width="461"><figcaption></figcaption></figure>

**Schritte:**

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f3b8e88622c250b5d11f0576c296d378414bf96d%2F%7B595C3E70-CED1-4912-A6E8-C88D680E9903%7D.png?alt=media" 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c3f201c93c6c856f7f18662c8ea82fa2c003e8de%2F%7B3863FEBE-6FF4-468F-B4D3-A7747BA24BD0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-525be5a3d11a9b8834309c181841d449d13c765d%2F%7BC488BB59-A9A6-4DFB-B938-5A3750FFBD80%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Das Makro ist jetzt bereit und funktionsfähig.

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

1. Fangen Sie die `POST` Anfrage ab, die den `MFA-Code` Parameter angeben.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3672181bbd5df883883eae782d5a77203cd591b5%2F%7BE49939DA-088C-4E64-96CC-34CD2A46A4F4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Senden Sie diese Anfrage an **Intruder**.
* Setzen Sie den Payload im `MFA-Code` Feld.
* Legen Sie einen Wertebereich von **0000 bis 9999**, mit einem Format von **4 erforderlichen Ziffern**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-78278bbb025425207b01cc78dbea415d4ea11e67%2F%7BC0CE4BB8-36E4-47F9-BC97-82B1FFB7FB68%7D.png?alt=media" alt="" width="394"><figcaption></figcaption></figure>

Ordnen Sie das Makro so zu, dass **der CSRF-Token automatisch aktualisiert wird** bei jeder Anfrage.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c9e9c533009cc059e9deb568e51cd7b30d58893d%2F%7BC167ABD2-994F-4D27-B3BE-B95DFB48A301%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Ergebnis**

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-229a1a4f28b1aea19f7b3b757caf5ec08da82557%2F%7BD4634311-3A29-461E-9A0E-79F7D5407B5F%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/authentication/2fa-bypass-via-brute-force.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.
