catalog

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

1. 漏洞描述

Relevant Link:
2. 漏洞触发条件

  1. . 找到前台文件上传点
  2. http://localhost/qibo/hy/choose_pic.php
  3.  
  4. . 上传后直接包含文件
  5. http://localhost/qibo/hr/listperson.php?FidTpl[list]=../upload_files/homepage/pic/0/xxxx/xxx.jpg
  6.  
  7. . Getshell

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

/hr/listperson.php

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

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

  1. function getTpl($html, $tplpath = '')
  2. {
  3. global $STYLE;
  4.  
  5. //$tplpath是我们外部传入的,黑客可以通过变量覆盖控制
  6. if($tplpath && file_exists($tplpath))
  7. {
  8. //如果文件存在,那么就直接return
  9. return $tplpath;
  10. }
  11. elseif($tplpath && file_exists(Mpath.$tplpath))
  12. {
  13. return Mpath.$tplpath;
  14. }
  15. elseif(file_exists(Mpath . "template/$STYLE/$html.htm"))
  16. {
  17. return Mpath."template/$STYLE/$html.htm";
  18. }
  19. else
  20. {
  21. return Mpath."template/default/$html.htm";
  22. }
  23. }

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

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

5. 防御方法

0x1: 任意文件包含注入点防御

/hr/listperson.php

  1. /* */
  2. if (!empty($FidTpl['list']))
  3. {
  4. unset($FidTpl['list']);
  5. }
  6. /**/
  7. $template_file=getTpl("list_$fidDB[mid]",$FidTpl['list']);
  8. fetch_label_value(array('pagetype'=>'','file'=>$template_file,'module'=>$webdb['module_id']));

0x2: 前台任意文件上传点防御

/hy/choose_pic.php

  1. if($action=='upload')
  2. {
  3. if(is_uploaded_file($_FILES[postfile][tmp_name]))
  4. {
  5. $array[name]=is_array($postfile)?$_FILES[postfile][name]:$postfile_name;
  6. $title=$title?$title:$array[name];
  7. $myname_str=explode(".",strtolower($array[name]));
  8. $myname=$myname_str[(count($myname_str)-)];
  9. if(!in_array($myname,array('gif','jpg'))) $msg="{$array[name]}图片只能是gif或者jpg的格式";
  10. ..

这个文件是前台提供用户上传图片之用,程序本身对文件扩展名做了限制(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. Method not found: '!!0[] System.Array.Empty()'.

    错误原因:程序里面没有可调用的方法(程序使用的是 .NET Framework 4.6,但是你自己的系统里面使用的不是 4.6版本) 解决方法:1.安装window sp1  ,下载地址是:https ...

  2. Oracle字符分隔函数(split)

    为了让 PL/SQL 函数返回数据的多个行,必须通过返回一个 REF CURSOR 或一个数据集合来完成.REF CURSOR 的这种情况局限于可以从查询中选择的数据,而整个集合在可以返回前,必须进行 ...

  3. ${pageContext.request.contextPath}无效

    发现在Tomcat7.0.58,在jsp页面使用${pageContext.request.contextPath}获取不到项目名称,网上找了很多答案试了都无效: 把Tomcat版本换成Tomcat7 ...

  4. mac下CornerstoneSVN出错 Description : The working copy is locked due to a previous error

    使用CornerStone工具update最新SVN代码报错:The working copy is locked due to a previous error,不仅无法上传,也无法更新,错误提示被 ...

  5. 用 Linux自带的logrotate 来管理日志

    大家可能都有管理日志的需要,比如定时压缩日志,或者当日志超过一定大小时就自动分裂成两个文件等.最近就接到这样一个小任务.我们的程序用的是C语言,用log4cpp的library来实现日志记录.但是问题 ...

  6. Nodejs爬虫进阶=>异步并发控制

    之前写了个现在看来很不完美的小爬虫,很多地方没有处理好,比如说在知乎点开一个问题的时候,它的所有回答并不是全部加载好了的,当你拉到回答的尾部时,点击加载更多,回答才会再加载一部分,所以说如果直接发送一 ...

  7. [HDOJ5451]Best Solver(乱搞)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5451 分析:A=5+2根号6 B=6-2根号6 n=1+2^x 那么A^n+B^n是整数 注意到0< ...

  8. TP学习笔记一(tp的目录结构 , tp的输出方式)

    一.ThinkPHP的介绍 //了解 MVC M - Model 模型 工作:负责数据的操作 V - View 视图(模板) 工作:负责前台页面显示 C - Controller 控制器(模块) 工作 ...

  9. import random 模块导入

    import random print(random.random()) #浮点数值 print(random.randint(1,2))#循环显示1,2 print(random.randrange ...

  10. JVM垃圾收集器介绍

    垃圾回收算法是GC的方法论,垃圾收集器就是内存回收的具体实现. 一.Serial 收集器 单线程收集器,在进行GC时,必须暂停所有的工作线程(Stop The World),直到GC收集结束. 缺点: ...