漏洞代码:

    public function myCache(){
        $a = "\nphpinfo();//";
        Cache::set("hack to cache",$a);
        return "cache ok!!!";
    }

访问:http://tp50.com/index.php/index/index/myCache

Thinkphp <= 5.0.10 缓存导致的Getshell

漏洞分析:

下断点分析

Thinkphp <= 5.0.10 缓存导致的Getshell

首先是Cache::set("hack to cache",$a);,该类没有实例化,进行自动加载机制进行实例化

Thinkphp <= 5.0.10 缓存导致的Getshell

然后先来到Cache::set方法中

Thinkphp <= 5.0.10 缓存导致的Getshell

随后就是先进入 init 的初始化方法中 接着继续进入connect方法中

Thinkphp <= 5.0.10 缓存导致的Getshell

先调用Cache::get方法,该方法中是返回 cache的相关的参数

Thinkphp <= 5.0.10 缓存导致的Getshell

然后返回 来到connecct方法中,该方法默认返回File类的实例化

Thinkphp <= 5.0.10 缓存导致的Getshell

最后进入 set 方法中

Thinkphp <= 5.0.10 缓存导致的Getshell

其中 file_put_contents 方法写入的内容可控 导致 缓存文件getshell

Thinkphp <= 5.0.10 缓存导致的Getshell

最后自己发现的是:tp5下面 如果web目录设置为./public下 那么也无法通过路由访问runtime

修复:

看一下修复之后的结果(v5.0.15)

Thinkphp <= 5.0.10 缓存导致的Getshell

文章参考:https://www.cnblogs.com/litlife/p/11241571.html

相关文章:

  • 2021-07-07
  • 2021-11-27
  • 2022-12-23
  • 2021-08-18
  • 2021-12-14
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2022-01-19
  • 2021-06-03
  • 2021-12-06
  • 2021-11-08
  • 2021-10-11
  • 2022-12-23
  • 2021-04-23
相关资源
相似解决方案