> 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/business-logic/bypassing-authentication-via-encryption-oracle.md).

# تجاوز المصادقة عبر مُولِّد التشفير

### تجاوز المصادقة عبر أوراكل التشفير

**وصف المختبر**

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

المعرّف المزوَّد:

* المستخدم: `wiener`
* كلمة المرور: `peter`

**الملاحظة الأولية**

في صفحة تسجيل الدخول، خيار **البقاء مسجّل الدخول** متاح.

<figure><img src="/files/3f5a27a862dfdddbc6dd6fbb3242e55d2a046597" alt=""><figcaption></figcaption></figure>

عند استخدامه، يتم إنشاء ملف تعريف ارتباط مشفّر في **Base64** ويتم تخزينه على جانب العميل.

<figure><img src="/files/836b4fb0fb3ec956415379c5db2c1523629d27f6" alt=""><figcaption></figcaption></figure>

```bash
echo '0HE6oMYJL//S1fLwttqR7WMF3EX4KJmvfFRI53qpVnk=' | base64 -d

# القيمة المفكوكة هي نصّ مشفّر ثنائي، وليست نصًا مقروءًا.
```

### تحديد أوراكل التشفير

عند إرسال تعليق صالح، لا يُلاحظ أي ردّ محدد.

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

ومع ذلك، إذا تسبب تعليق في خطأ بالتطبيق (مثل عنوان بريد إلكتروني غير صالح)، فإن الخادم:

* يعرض رسالة خطأ على الشاشة؛

{% code overflow="wrap" %}

```bash
csrf=cFMQUjAyzETtEr8TLsoir7V5p4C3m4ZG&postId=4&comment=test&name=test&email=test&website=https://localhost
```

{% endcode %}

* ينشئ ملف تعريف ارتباط جديد `إشعار`\*\*، مشفّر.

المحتوى المعروض هو على سبيل المثال:

<figure><img src="/files/60245757b90282bf338221c9f2e1e1939ee8fafe" alt=""><figcaption></figcaption></figure>

وهذا يوضح أن:

* الخادم \*\*يفك تشفير محتوى `إشعار` ملف تعريف الارتباط؛

<figure><img src="/files/6aa12222d0b3c60d8b6620d986b8b6fb96d4fdad" alt=""><figcaption></figcaption></figure>

وبالتالي يعمل الخادم كـ **أوراكل للتشفير وفك التشفير**.

* النص المفكوك هو **ويُعاد إدخاله في استجابة HTML**.

<figure><img src="/files/443c3369f143c1cd30ede9d6be7e0f28d79f4862" alt=""><figcaption></figcaption></figure>

### الارتباط بملف تعريف الارتباط

من خلال حقن القيمة المشفرة لملف تعريف الارتباط \*\*

الصيغة الملحوظة هي:

<figure><img src="/files/41323bf13e12775a0c6320924130bac01081c37f" alt=""><figcaption></figcaption></figure>

وهذا يتوافق بوضوح مع:

* اسم مستخدم؛
* طابع زمني.

#### تزوير هوية مسؤول

الهدف هو جعل الخادم يشفّر السلسلة التالية:

```bash
administrator:1766913113564
```

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

للقيام بذلك، تُحقن هذه القيمة في الحقل الضعيف (تعليق/بريد إلكتروني غير صالح)، مما يؤدي إلى:

* عرض رسالة الخطأ التي تحتوي على هذه السلسلة؛

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

توليد ملف `إشعار` تعريف ارتباط جديد، متضمناً النص المحقون.

{% code overflow="wrap" %}

```bash
Set-Cookie: notification=VQbs3ex4CbvKjTm0LM5wuZa79pnAzKI9MEsa1O0MbX%2fJpfl9baj6yL3ryxh4u6nyiWHVwxP7%2fVDPyft%2f1qAbbQ%3d%3d; HttpOnly
```

{% endcode %}

### تحديد خوارزمية التشفير

عند اقتطاع القيمة المشفرة بشكل عشوائي، يُرجع الخادم الخطأ التالي

```bash
PTBLGtTtDG1/yaX5fW2o%2bsi968sYeLup8olh1cMT%2b/1Qz8n7f9agG20%3d
```

`يجب أن يكون طول الإدخال مضاعفًا لـ 16 عند فك التشفير باستخدام شفرة ذات حشو`

<figure><img src="/files/218f277976238884807a0c6940389f59fefb23d4" alt=""><figcaption></figcaption></figure>

وهذا يشير بوضوح إلى استخدام **AES مع الحشو**، ويعمل في كتل بحجم **16 بايت**.

<figure><img src="/files/00931f20c0d3237941bbbc74bf6daf36faf84729" alt=""><figcaption></figcaption></figure>

#### التلاعب بكتل التشفير

المشكلة التي تمت مواجهتها هي وجود محارف حشو غير صالحة في نهاية الرسالة. / ولإصلاح ذلك، تسبق السلسلة المحقونة محارف تعبئة لمحاذاة الكتل بشكل صحيح:

```
xxxxxxxxxadministrator:1766913113564
```

<figure><img src="/files/7b3b9c7b9dd4967684ab4f94e205b9868ceb81bd" alt=""><figcaption></figcaption></figure>

بعد ذلك يتم إنشاء ملف تعريف ارتباط مشفّر جديد.

VQbs3ex4CbvKjTm0LM5wuZJqwlVboMZ2IzNuiTfVH6iHj9RZUT59d5kGoS64tVE5wWiEfmp6VbJG%2bb%2fNW5%2bblA%3d%3d

### قصّ وإعادة تركيب ملف تعريف الارتباط

بحذف أول **كتلتين مشفرتين** (المقابلتين للتعبئة)، تبقى فقط الكتل التي تحتوي على:

<figure><img src="/files/73af04778c9596747b4042d05f800b997d23665a" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/35d8ced156e805f87c4b0d0f096831ff1c1d8997" alt=""><figcaption></figcaption></figure>

تقبل الخادم هذه القيمة المشفرة النهائية.

```
h4/UWVE%2bfXeZBqEuuLVROcFohH5qelWyRvm/zVufm5Q%3d
```

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

#### التحايل على المصادقة

الخطوات النهائية:

1. احذف ملف تعريف ارتباط الجلسة الحالي.
2. استبدل قيمة ملف تعريف الارتباط \*\*
3. حدّث الصفحة.

<figure><img src="/files/06c93d996a9f1df6b7fe58ddb70e25227e2c64f7" 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/business-logic/bypassing-authentication-via-encryption-oracle.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.
