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. java反射详解(转)

    本篇文章依旧采用小例子来说明,因为我始终觉的,案例驱动是最好的,要不然只看理论的话,看了也不懂,不过建议大家在看完文章之后,在回过头去看看理论,会有更好的理解. 下面开始正文. [案例1]通过一个对象 ...

  2. 在项目中代替DevExpress(一)

    从Delphi时代开始一直都是DevExpress系列控件的忠实用户,到现在已经有10多个年头了.DevExpress里面的控件基本从头到尾都用过一次,而且也开发过很多基于DevExpress的子控件 ...

  3. HBase初探

    string hbaseCluster = "https://charju.azurehdinsight.net"; string hadoopUsername = "账 ...

  4. js下拉框

    Js下拉框   http://sc.chinaz.com/tag_jiaoben/XiaLaKuang.html

  5. [BZOJ2768][JLOI2010]冠军调查(最小割)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2768 分析: 如果一个点i认为是0,则连一条S->i,如果认为是1,则i-> ...

  6. codevs 4543 treap 模板

    type rec=record lc,rc,v,rnd,size,w,fa:longint; end; var n,root,tot,ans,opt,x,i,po:longint; tr:array[ ...

  7. 文本域的宽度和高度应该用cols和rows来控制,还是 用width和height来控制

    文本域宽度如果用cols来控制,缩放网页的时候文本域的宽度不会自动变化 用width来表示就会跟着网页缩放而缩放 看到下面一段文字: 对于内容至上的网页,在禁用CSS的情况下,HTML内容要做到易于阅 ...

  8. [转]Windows系统注册表知识完全揭密

    来源:http://www.jb51.net/article/3328.htm Windows注册表是帮助Windows控制硬件.软件.用户环境和Windows界面的一套数据文件,注册表包含在Wind ...

  9. Linux运维人员共用root帐户权限审计

    Linux运维人员共用root帐户权限审计 2016-11-02 运维部落 一.应用场景 在中小型企业,公司不同运维人员基本都是以root 账户进行服务器的登陆管理,缺少了账户权限审计制度.不出问题还 ...

  10. C#反射设置属性值和获取属性值

    /// /// 获取类中的属性值 /// /// /// /// public string GetModelValue(string FieldName, object obj) { try { T ...