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的更多相关文章

  1. include file和include virtual的区别

    1.#include file 包含文件的相对路径,#include virtual包含文件的虚拟路径. 2.在同一个虚拟目录内,<!--#include file="file.asp ...

  2. 一种封装Retrofit的方法,可以自动解析Gson,回避Method return type must not include a type variable or wildcard: retrofit2.Call<T>的问题

    封装目的:屏蔽底层实现,提供统一接口,并支持Gson自动转化 最初封装: //请求方法 interface RequestListener { interface PostListener { @PO ...

  3. 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 ...

  4. html中#include file的使用方法

    有两个文件a.htm和b.htm,在同一文件夹下a.htm内容例如以下 <!-- #include file="b.htm" --> b.htm内容例如以下 今天:雨 ...

  5. html 中 #include file 的用法

    有两个文件a.htm和b.htm,在同一目录下a.htm内容如下 <!-- #include file="b.htm" --> b.htm内容如下 今天:雨 31 ℃- ...

  6. HTML中include file的用法

    语法 <!-- #include PathType = "FileName" --> 参数 PathType  路径类型 路径可为以下某种类型: 文件 该文件名是带有  ...

  7. <%@ include file=""%>与<jsp:include page=""/>区别(转)

    http://www.iteye.com/topic/312500/ 我们都知道在jsp中include有两种形式,分别是Include指令:<%@ include file="&qu ...

  8. 静态include与动态include的区别

    jsp中的include有两种形式,分别是:<%@ include file=""%><jsp:include page="" flush=& ...

  9. ASP入门(十七)-ASP #include

    通过使用 #include 指令,您可以在服务器执行 ASP 文件之前,把另一个 ASP 文件的内容插入到这个 ASP 文件中. 如何使用 #include 指令 这里有一个名为 mypage.asp ...

随机推荐

  1. Linux 信号详解二(信号分类,信号处理,kill)

    信号分类 信号分为可靠信号和不可靠信号 不可靠信号的缺点 ①:处理完信号,需要重新再注册信号:②信号可能丢失. Linux已经对缺点①做了优化,现在的不可靠问题主要指的是信号可能丢失 信号还可以分为实 ...

  2. Visual Studio2012打开时弹出“遇到异常:这可能是由某个扩展导致的”错误的解决办法

    Visual Studio2012打开时弹出"遇到异常:这可能是由某个扩展导致的"错误的解决办法: 具体问题如下: 分析原因:网上搜集了以下,出现异常的原因是安装了第三方控件,然后 ...

  3. Bink Player

    class CBIKMaterial { public: CBIKMaterial(); ~CBIKMaterial(); bool Init(const char *pFileName); void ...

  4. 纯手工打造漂亮的垂直时间轴,使用最简单的HTML+CSS+JQUERY完成100个版本更新记录的华丽转身!

    前言 FineUI控件库发展至今已经有 5 个年头,目前论坛注册的QQ会员 5000 多人,捐赠用户 500 多人(捐赠用户转化率达到10%以上,在国内开源领域相信这是一个梦幻数字!也足以证明Fine ...

  5. 《DOM启蒙》 随笔

    使用 Javascript 字符串创建并向 DOM 中添加元素与文本节点 innerHTML.outerHTML.textContent 及 insertAdjacentHTML() 属性和方法提供了 ...

  6. [poj2484]A Funny Game(对称博弈)

    题目:http://poj.org/problem?id=2484 题意:n个石子围成一个圈,两个人轮流取,每次可以取一个石子或者相邻的两个石子,问先手胜还是后手胜 分析: 典型的对称博弈 如果n&g ...

  7. 获取用户请求过来的URL

    document.referer 一段JS搞定

  8. UTF-8 's format

    几篇比较好的博客 古腾龙的博客:编码规则(UTF-8 GBK) GBK 千千秀字 shell set man ascii可以查看ascii码表,man utf-8看以查看utf-8的帮助 Unicod ...

  9. PotPlayer 1.6.52965 美化版|视频播放器

    Potplayer播放器,基本上可以解析大部分的视频格式.作为单机版的视频播放器很不错的选择! Potplayer,只为播放而生! exp: 点击下载

  10. python2.7到python3代码转换脚本2to3的一些介绍

       你的位置: Home ‣ Dive Into Python 3 ‣ 难度等级: ♦♦♦♦♦   使用2to3将代码移植到Python 3 ❝ Life is pleasant. Death is ...