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 ...
随机推荐
- Method not found: '!!0[] System.Array.Empty()'.
错误原因:程序里面没有可调用的方法(程序使用的是 .NET Framework 4.6,但是你自己的系统里面使用的不是 4.6版本) 解决方法:1.安装window sp1 ,下载地址是:https ...
- Oracle字符分隔函数(split)
为了让 PL/SQL 函数返回数据的多个行,必须通过返回一个 REF CURSOR 或一个数据集合来完成.REF CURSOR 的这种情况局限于可以从查询中选择的数据,而整个集合在可以返回前,必须进行 ...
- ${pageContext.request.contextPath}无效
发现在Tomcat7.0.58,在jsp页面使用${pageContext.request.contextPath}获取不到项目名称,网上找了很多答案试了都无效: 把Tomcat版本换成Tomcat7 ...
- 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,不仅无法上传,也无法更新,错误提示被 ...
- 用 Linux自带的logrotate 来管理日志
大家可能都有管理日志的需要,比如定时压缩日志,或者当日志超过一定大小时就自动分裂成两个文件等.最近就接到这样一个小任务.我们的程序用的是C语言,用log4cpp的library来实现日志记录.但是问题 ...
- Nodejs爬虫进阶=>异步并发控制
之前写了个现在看来很不完美的小爬虫,很多地方没有处理好,比如说在知乎点开一个问题的时候,它的所有回答并不是全部加载好了的,当你拉到回答的尾部时,点击加载更多,回答才会再加载一部分,所以说如果直接发送一 ...
- [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< ...
- TP学习笔记一(tp的目录结构 , tp的输出方式)
一.ThinkPHP的介绍 //了解 MVC M - Model 模型 工作:负责数据的操作 V - View 视图(模板) 工作:负责前台页面显示 C - Controller 控制器(模块) 工作 ...
- import random 模块导入
import random print(random.random()) #浮点数值 print(random.randint(1,2))#循环显示1,2 print(random.randrange ...
- JVM垃圾收集器介绍
垃圾回收算法是GC的方法论,垃圾收集器就是内存回收的具体实现. 一.Serial 收集器 单线程收集器,在进行GC时,必须暂停所有的工作线程(Stop The World),直到GC收集结束. 缺点: ...