鉴于smarty模板存在许多cve编号,这里将结合cve版本来进行讲解

CVE-2017-1000480

这里以春秋云境上的实例进行讲解,打开给出的网站,直接给出了代码

?eval=*/phpinfo();/*

把等号后面那串传给eval,成功执行phpinfo 观察代码

$smarty->display('test:'.$_GET['eval']);

值是通过这里传入的

在/libs/sysplugins/smarty_internal_templatebase.php找到了定义display的地方 在display这里调用了execute函数,再接着往下找

找到定义execute这里,重点在createTemplate

            $saveVars = false;

            $template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false);
            if ($this->_objType == 1) {
                // set caching in template object
                $template->caching = $this->caching;

这里会将我们传的参数创建成模板

再往下看216行这处代码,这里出现了render,继续在samrty_internal_template类里找 追到

samrty_internal_template.php

在第175行这里出现了对render的定义