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 ...
随机推荐
- 路由系统的核心对象——Router
路由系统的核心对象--Router ASP.NET Core应用中的路由机制实现在RouterMiddleware中间件中,它的目的在于通过路由解析为请求找到一个匹配的处理器,同时将请求携带的数据以路 ...
- easyui layout 折叠后显示标题
(function($){ var buttonDir = {north:'down',south:'up',east:'left',west:'right'}; $.extend($.fn.layo ...
- 使用EasyUI布局时出现混乱瞬间的解决方法
在所有form代码之前加遮罩层 <div id='PageLoadingTip' style="position: absolute; z-index: 1000; top: 0px; ...
- ASP.NT运行原理和页面生命周期详解及其应用
ASP.NT运行原理和页面生命周期详解及其应用 1. 下面是我画的一张关于asp.net运行原理和页面生命周期的一张详解图.如果你对具体不太了解,请参照博客园其他帖子.在这里我主要讲解它的实际应用. ...
- 为什么Javascript中的基本类型能调用方法?
我们从一道笔试题说起: var str = 'string'; str.pro = 'hello'; console.log(str.pro + 'world'); 输出啥?要理解这个问题,我们得从头 ...
- mysql创建触发器
触发器语句只有一句话 可以省略begin和end CREATE trigger `do_praise` after insert on praise for each row update post ...
- 【JavaEE企业应用实战学习记录】struts2实现登录并获取各个范围的数据
package sanglp; import com.opensymphony.xwork2.*; /** * Created by Administrator on 2016/10/6. */ pu ...
- “Ceph浅析”系列之七——关于Ceph的若干想法
本篇文章的内容,主要是笔者在调研分析Ceph过程中产生的一些思考.因为其中的内容比较自由发散,且大多是笔者的个人见解,故此另启一文进行讨论. 关于Ceph的性能 目前为止,本系列的文章中没有涉及到Ce ...
- ubuntu静态IP配置
1. 修改配置文件/etc/network/interfacesroot@ubuntu:~# sudo gedit /etc/network/interfaces 添加以下内容:auto eth0 ...
- 【BZOJ 3165】【HEOI 2013】Segment
往区间上覆盖一次函数,做法是用线段树维护标记永久化. 每次都忘了线段树要4倍空间,第一次交总是RE,再这么手残的话考场上就真的要犯逗了. #include<cstdio> #include ...