> 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/zh/web/ssti/ssti-information-disclosure-via-python-user-objects.md).

# 通过 Python 用户对象进行 SSTI 信息泄露

### 通过用户提供的对象进行带信息泄露的服务器端模板注入

本实验的目标是利用由于对象传递给模板的方式而导致的 SSTI 来获取敏感数据，尤其是框架的密钥。/ 我们有一个账户： `content-manager: C0nt3ntM4n4g3r`.

#### ITST 的分析与识别

第一步是使用以下表达式使模板引擎出错：

```
{{}}
```

<figure><img src="/files/82beaed05996c2a0a9ae2f315e787a87990e149e" alt=""><figcaption></figcaption></figure>

* 这证实我们可以注入服务器端模板代码。

然后尝试通过注入以下内容显示更多调试信息：/ `{% debug %}`

```python
{% debug %}
```

* 然而，输出中没有出现任何有趣或敏感的信息。

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

#### 密钥恢复

* 由于传递给模板的对象可访问配置，因此可以尝试通过以下参数直接读取框架的密钥：/ `{{settings.SECRET_KEY}}`

```python
{{settings.SECRET_KEY}}
```

<figure><img src="/files/0564fcf4d3aa490104eb165228c4889c1ed6cc9e" 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/zh/web/ssti/ssti-information-disclosure-via-python-user-objects.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.
