qibocms /hr/listperson.php File Arbitrarily Include Vul Via Variable Uninitialization && Front Page Upload WEBSHELL
catalog
. 漏洞描述
. 漏洞触发条件
. 漏洞影响范围
. 漏洞代码分析
. 防御方法
. 攻防思考
1. 漏洞描述
Relevant Link:
2. 漏洞触发条件
. 找到前台文件上传点
http://localhost/qibo/hy/choose_pic.php . 上传后直接包含文件
http://localhost/qibo/hr/listperson.php?FidTpl[list]=../upload_files/homepage/pic/0/xxxx/xxx.jpg . Getshell
3. 漏洞影响范围
4. 漏洞代码分析
/hr/listperson.php
//获取标签内容
//注意这里的$FidTpl 这里并没有初始化 导致黑客可以通过qibo的"模拟GPC注册机制"覆盖这个变量的值
$template_file=getTpl("list_$fidDB[mid]",$FidTpl['list']);
fetch_label_value(array('pagetype'=>'','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. 防御方法
0x1: 任意文件包含注入点防御
/hr/listperson.php
/* */
if (!empty($FidTpl['list']))
{
unset($FidTpl['list']);
}
/**/
$template_file=getTpl("list_$fidDB[mid]",$FidTpl['list']);
fetch_label_value(array('pagetype'=>'','file'=>$template_file,'module'=>$webdb['module_id']));
0x2: 前台任意文件上传点防御
/hy/choose_pic.php
if($action=='upload')
{
if(is_uploaded_file($_FILES[postfile][tmp_name]))
{
$array[name]=is_array($postfile)?$_FILES[postfile][name]:$postfile_name;
$title=$title?$title:$array[name];
$myname_str=explode(".",strtolower($array[name]));
$myname=$myname_str[(count($myname_str)-)];
if(!in_array($myname,array('gif','jpg'))) $msg="{$array[name]}图片只能是gif或者jpg的格式";
..
这个文件是前台提供用户上传图片之用,程序本身对文件扩展名做了限制(gif、jpg),作为防御方来说,对文件内容进行PHP代码检测意义不大,因为本身gif、jpg格式图片是不能被WEB Server执行的,只有存在其他文件inlcude包含漏洞的时候,图片文件中的PHP代码才能被引入执行,因此,我们只要堵住文件include包含漏洞就可以了
6. 攻防思考
Copyright (c) 2015 LittleHann All rights reserved
qibocms /hr/listperson.php File Arbitrarily Include Vul Via Variable Uninitialization && Front Page Upload WEBSHELL的更多相关文章
- include file和include virtual的区别
1.#include file 包含文件的相对路径,#include virtual包含文件的虚拟路径. 2.在同一个虚拟目录内,<!--#include file="file.asp ...
- 一种封装Retrofit的方法,可以自动解析Gson,回避Method return type must not include a type variable or wildcard: retrofit2.Call<T>的问题
封装目的:屏蔽底层实现,提供统一接口,并支持Gson自动转化 最初封装: //请求方法 interface RequestListener { interface PostListener { @PO ...
- QTVA-2015-198545、WooYun-2015-104148 .NET Framework Arbitrary File Permissions Modify Vul
catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...
- html中#include file的使用方法
有两个文件a.htm和b.htm,在同一文件夹下a.htm内容例如以下 <!-- #include file="b.htm" --> b.htm内容例如以下 今天:雨 ...
- html 中 #include file 的用法
有两个文件a.htm和b.htm,在同一目录下a.htm内容如下 <!-- #include file="b.htm" --> b.htm内容如下 今天:雨 31 ℃- ...
- HTML中include file的用法
语法 <!-- #include PathType = "FileName" --> 参数 PathType 路径类型 路径可为以下某种类型: 文件 该文件名是带有 ...
- <%@ include file=""%>与<jsp:include page=""/>区别(转)
http://www.iteye.com/topic/312500/ 我们都知道在jsp中include有两种形式,分别是Include指令:<%@ include file="&qu ...
- 静态include与动态include的区别
jsp中的include有两种形式,分别是:<%@ include file=""%><jsp:include page="" flush=& ...
- ASP入门(十七)-ASP #include
通过使用 #include 指令,您可以在服务器执行 ASP 文件之前,把另一个 ASP 文件的内容插入到这个 ASP 文件中. 如何使用 #include 指令 这里有一个名为 mypage.asp ...
随机推荐
- caffe的python接口学习(3):训练模型(training)
如果不进行可视化,只想得到一个最终的训练model, 那么代码非常简单,如下 : import caffe caffe.set_device(0) caffe.set_mode_gpu() solve ...
- RelayCommand
RelayCommand Mvvm最大的特点就是分离了View和ViewModel,将数据的显示和业务逻辑分开.使用WPF的Binding,我们不仅能够 将数据从ViewModel绑定到View,同时 ...
- Qt学习笔记 信号和槽
槽和普通c++成员函数一样只可以为虚函数,也可以被重用,可以是公有的也可以是私有的,也可以被其它的c++函数调用; 参数也是任意的 唯一不同的是本槽和信号是可以连在一起的,和c#的事件差不多.相连后每 ...
- Spring MVC 急速集成 Shiro 实录
相信有很多的程序员,不愿意进行用户管理这块代码实现. 原因之一,不同的JavaEE 系统,用户管理都会有个性化的实现,逻辑很繁琐. 而且是系统门面,以后背锅的几率非常大,可谓是低收益高风险. 最近在系 ...
- 大学回顾和C与PHP之路
我去年毕业,从事PHP学习和开发一年多. background:medical muti-media electric web; 先讲一下我的背景吧,我大学的学校是一个医科学校,然而专业是计算机动漫设 ...
- Chrome 监听 console 打开
这个算是 Chrome only 其他的我没测试,也不想测试.因为我的控制台脚本仅仅在 Chrome 下加载. 如果你需要全平台,那么这肯定不是你需要的结果. 需求 其实我很早就想折腾这个了,但是,, ...
- [BZOJ1264][AHOI2006]Match(DP+树状数组)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1264 分析: 考虑做一般的LCS的时候,更新结果的条件是a[i]==b[j]时候 于是 ...
- MATLAB axis和axes的区别
axis中文为“轴”之意,在matlab中用于控制坐标轴的范围和样式(颜色等). axis([XMIN XMAX YMIN YMAX]) 设置当前所绘图像的x轴和y轴的范围.axis([XMIN XM ...
- SqlServer——批量操作(批量添加,删除)
批量添加数据: 一条insert语句批量插入多条记录 常见的insert语句,向数据库中,一条语句只能插入一条数据: insert into persons (id_p, lastname , fir ...
- memcached安装配置
简述: memcached,开源的分布式缓存数据系统.高性能的NOSQL . Linux 一.环境配置与安装 01.编译准备环境 yum install -y gcc make cmake autoc ...