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 ...
随机推荐
- [py]文件 字符串 列表特例
文件 readlines 列表 readline 字符串 read 字符串 列表---拆分---小列表 f=file('test.log','r') for line in f.readlin ...
- Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...
- Caffe学习系列(2):数据层及参数
要运行caffe,需要先创建一个模型(model),如比较常用的Lenet,Alex等, 而一个模型由多个屋(layer)构成,每一屋又由许多参数组成.所有的参数都定义在caffe.proto这个文件 ...
- Java程序设计的DOS命令基础
Java程序设计的DOS命令基础 用户使用操作系统和软件有两种方式:命令行界面(Command Line Interface,CLI)和图形界面(Graphical User Interface,GU ...
- hdu5444Elven Postman(主席树思想的应用)
主席树这个概念应该不陌生吧!恩?不会, 戳这里. 主席树(函数式线段树)用的是函数思想,一个节点开数组用来保存自己的左右节点,这样节省许多不必要的空间,还可以保存许多历史状态.而这里我们用的是主席树的 ...
- Scala函数式编程进阶
package com.dtspark.scala.basics /** * 函数式编程进阶: * 1,函数和变量一样作为Scala语言的一等公民,函数可以直接赋值给变量: * 2, 函数更长用的方式 ...
- 探究JVM——垃圾回收
垃圾回收主要考虑三件事情:哪些内存需要回收?什么时候回收?如何回收? 一.哪些内存需要回收? 堆内存:对于JVM 来说,垃圾回收主要是针对堆内存中的对象实例. 方法区:垃圾收集行为在方法区是比较少出现 ...
- [POJ3696]The Luckiest number(数论)
题目:http://poj.org/problem?id=3696 题意:给你一个数字L,你要求出一个数N,使得N是L的倍数,且N的每位数都必须是8,输出N的位数(如果不存在输出0) 分析: 首先我们 ...
- mac搭建mamp环境
1 先安装homebrew; 执行:cd /usr/local; 非root用户执行: ruby -e "$(curl -fsSL https://raw.githubusercontent ...
- Php 安装 curl
一.用好tab键.输入一部分,就按两次tab键,看看到底应该安什么