> 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/broken-2fa-logic.md).

# Fehlerhafte 2FA-Logik

### Fehlerhafte 2FA-Logik

Die Anwendung führt eine Zwei-Faktor-Authentifizierung ein: / Nach Login/Passwort wird ein **2FA-Code** wird gesendet von **E-Mail**. / Wir haben:

* Unsere Anmeldedaten: `wiener:peter`
* Der Benutzername des Opfers: `carlos`

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

Zugriff auf **Mailserver** um 2FA-Codes zu empfangen

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

#### Beobachteter Ablauf

1. Nach dem ersten Anmeldeschritt sendet die Anwendung einen 2FA-Code per E-Mail.
2. Der zweite Schritt (`/login2`) prüft diesen Code.
3. Der Benutzer, für den die 2FA gültig ist, wird über das **`verify`** Cookie verändert.

Beispiel für eine Anfrage an den zweiten Schritt:

```http
GET /login2 HTTP/2
Host: 0a7500ab0376700f81a18e2c00f200a8.web-security-academy.net
Cookie: session=cNFHPofUz1wxXQpsZZN7yIiKQklG1Ygd; verify=carlos
```

Hier erzwingen wir den `verify` Cookie auf `carlos` sodass die 2FA-Prüfung für das Konto des Opfers durchgeführt wird.

#### Brute-Force-Angriff auf den 2FA-Code

1. Die 2FA-Validierungsanfrage wird an **Intruder** (oder gleichwertig), indem die Anfrage mit folgendem Inhalt gezielt angegriffen wird:

```bash
mfa-code=XXXXX
```

<figure><img src="/files/4a4b925a9d9e9f8b0ac80df009402b6e0c690a0e" alt=""><figcaption></figcaption></figure>

* Das **Payload** ist so konfiguriert, dass alle möglichen Code-Kombinationen getestet werden, von `0000` zu `9999` (d. h. 10.000 Werte).

Wir verwenden das Cookie:

```bash
verify=carlos
```

* damit alle Code-Tests für das Konto von **carlos**.

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

* In den Einstellungen wird der Antwort eine \*\*Filterbedingung\*\* hinzugefügt, um diejenigen zu ignorieren, die die Meldung enthalten:
* `Falscher Sicherheitscode`

<figure><img src="/files/10e05387cea24d25aebf6455d6982e93469504f9" alt=""><figcaption></figcaption></figure>

1. Wir starten den Brute-Force-Angriff.
2. Unter den Antworten finden wir diejenige, die die Fehlermeldung nicht mehr enthält und einen \*\*HTTP-Code 302\*\* (Weiterleitung) zurückgibt. / → Diese Antwort entspricht dem **korrekten 2FA-Code** im Namen von **carlos**.

<figure><img src="/files/1e37e29961e8d9d316c372acc347a9cfebd8ba93" 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/broken-2fa-logic.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.
