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

# منطق المصادقة الثنائية المعطوب

### منطق 2FA المكسور

يُدخل التطبيق المصادقة الثنائية: / بعد تسجيل الدخول/كلمة المرور، يتم **رمز 2FA** يُرسل عبر **البريد الإلكتروني**. / لدينا:

* بيانات الاعتماد الخاصة بنا: `wiener:peter`
* اسم المستخدم الخاص بالضحية: `carlos`

<figure><img src="/files/0ac4ed38c87c2c699e7e439d390011e6654a18f3" alt=""><figcaption></figcaption></figure>

الوصول إلى **خادم البريد** لتلقي رموز 2FA

<figure><img src="/files/31c58882349494b6ff3900210f895f28c59f429b" alt=""><figcaption></figcaption></figure>

#### العملية المرصودة

1. بعد خطوة تسجيل الدخول الأولى، يرسل التطبيق رمز 2FA عبر البريد الإلكتروني.
2. الخطوة الثانية (`/login2`) تتحقق من هذا الرمز.
3. يتم تحديد المستخدم الذي تكون 2FA صالحة له عبر **`verify`** ملف تعريف الارتباط.

مثال على طلب إلى الخطوة الثانية:

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

هنا، نفرض `verify` الملفّ Cookie إلى `carlos` حتى يتم إجراء فحص 2FA على حساب الضحية.

#### تخمين رمز 2FA بالقوة الغاشمة

1. يتم إرسال طلب التحقق من 2FA إلى **Intruder** (أو ما يعادله) عبر استهداف الطلب الذي يحتوي على:

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

<figure><img src="/files/93102f71408000b1620ba7997b19e0aacd440dfe" alt=""><figcaption></figcaption></figure>

* الـ **الحمولة** مُهيّأ لاختبار جميع التركيبات الممكنة للرمز، من `0000` إلى `9999` (أي 10,000 قيمة).

نستخدم ملف تعريف الارتباط:

```bash
verify=carlos
```

* لتُجرى جميع اختبارات الرموز على حساب **carlos**.

<figure><img src="/files/887a11c51118df3bdcd0b47405742f2edb0e64a9" alt=""><figcaption></figcaption></figure>

* في الإعدادات، تتم إضافة \*\*شرط تصفية\*\* إلى الاستجابة لتجاهل تلك التي تحتوي على الرسالة:
* `رمز الأمان غير صحيح`

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

1. نبدأ هجوم القوة الغاشمة.
2. من بين الاستجابات، نجد الاستجابة التي لم تعد تحتوي على رسالة الخطأ وتُرجع \*\*رمز HTTP 302\*\* (إعادة توجيه). / → هذه الاستجابة تقابل **رمز 2FA الصحيح** بالنيابة عن **carlos**.

<figure><img src="/files/3f8f1481a0efa4d1b60b6706b668ef26c3157794" 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/ar/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.
