首页 > Web开发 > 详细

qibocms /hr/listperson.php File Arbitrarily Include Vul Via Variable Uninitialization & Getshell

时间:2015-08-05 17:55:34      阅读:506      评论:0      收藏:0      [点我收藏+]

catalog

1. 漏洞描述
2. 漏洞触发条件
3. 漏洞影响范围
4. 漏洞代码分析
5. 防御方法
6. 攻防思考

 

1. 漏洞描述

Relevant Link:
2. 漏洞触发条件

1. 找到前台文件上传点
http://localhost/qibo/hy/choose_pic.php

2. 上传后直接包含文件
http://localhost/qibo/hr/listperson.php?FidTpl[list]=../upload_files/homepage/pic/0/xxxx/xxx.jpg

3. Getshell


3. 漏洞影响范围
4. 漏洞代码分析

/hr/listperson.php

//获取标签内容
//注意这里的$FidTpl 这里并没有初始化 导致黑客可以通过qibo的"模拟GPC注册机制"覆盖这个变量的值
$template_file=getTpl("list_$fidDB[mid]",$FidTpl[list]);
fetch_label_value(array(pagetype=>4,file=>$template_file,module=>$webdb[module_id]));
..
//包含文件
require($template_file);

继续跟进$template_file=getTpl("list_$fidDB[mid]",$FidTpl[‘list‘]);

function getTpl($html, $tplpath = ‘‘)
{ 
    global $STYLE;

    //$tplpath是我们外部传入的,黑客可以通过变量覆盖控制
    if($tplpath && file_exists($tplpath))
    { 
        //如果文件存在,那么就直接return 
        return $tplpath;
    }
    elseif($tplpath && file_exists(Mpath.$tplpath))
    { 
        return Mpath.$tplpath; 
    }
    elseif(file_exists(Mpath . "template/$STYLE/$html.htm"))
    { 
        return Mpath."template/$STYLE/$html.htm"; 
    }
    else
    { 
        return Mpath."template/default/$html.htm"; 
    } 
}

回到/hr/listperson.php的require($template_file),return后就直接包含了该文件,程序没有对带包含的文件路径进行任何验证、限制,导致了可以直接包含任意格式、任意内容的文件
Relevant Link:

http://www.wooyun.org/bugs/wooyun-2014-081470


5. 防御方法

/hr/listperson.php

/* */
if (!empty($FidTpl[list])) 
{
    unset($FidTpl[list]);
} 
/**/
$template_file=getTpl("list_$fidDB[mid]",$FidTpl[list]);
fetch_label_value(array(pagetype=>4,file=>$template_file,module=>$webdb[module_id]));


6. 攻防思考

Copyright (c) 2015 Little5ann All rights reserved

 

qibocms /hr/listperson.php File Arbitrarily Include Vul Via Variable Uninitialization & Getshell

原文:http://www.cnblogs.com/LittleHann/p/4705280.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!