tp 6.0.9反序列化漏洞

环境搭建
安装好composer
安装教程:https://blog.csdn.net/qq_15941409/article/details/81233168

composer create-project topthink/think=6.0.x-dev thinkphp-v6.0
cd thinkphp-v6.0
php think run

正常的逻辑都是从__destruct方法入手,这里全局搜素一下

vendor\league\flysystem-cached-adapter\src\Storage\AbstractCache.php下找到了一个___destruct,

public function __destruct()
    {
        if (! $this->autosave) {
            $this->save();
        }
    }

找一个类掉用了save方法,并且有可以利用的地方
在vendor/league/flysystem-cached-adapter/src/Storage/Adapter.php找到了一个save方法

public function save()
    {
        $config = new Config();
        $contents = $this->getForStorage();
        if ($this->adapter->has($this->file)) {
            $this->adapter->update($this->file, $contents, $config);
        } else {
            $this->adapter->write($this->file, $contents, $config);
        }
    }

这里 t h i s − > a d a p t e r − > h a s ( this->adapter->has( this>adapter>has(this->file)判断文件是否存在
可以看到这里可以使用write进行写文件,其实update跟write的构造链是一样的,如果存在的话就给他覆盖了
我们找找哪一个类调用了write方法
\League\Flysystem\Adapter\Local

public function write($path, $contents, Config $config)
    {
        $location = $this->applyPathPrefix($path);
        $this->ensureDirectory(dirname($location));
    if (($size = file_put_contents($location, $contents, $this->writeFlags)) === false) {
        return false;
    }

    $type = 'file';
    $result = compact('contents', 'type', 'size', 'path');

    if ($visibility = $config->get('visibility')) {
        $result['visibility'] = $visibility;
        $this->setVisibility($path, $visibility);
    }

由file_put_contents函数可以看到这里进行了写文件的操作
我们继续看看参数是否可控
$path是我们传进来的文件名
applyPathPrefix()将文件左边的斜杠(“/”)去除
ensureDirectory 保证目录存在
l o c a t i o n 我们已经控制了继续看看 location我们已经控制了 继续看看 location我们已经控制了继续看看contents怎么进行控制
$contents = $this->getForStorage();
public function getForStorage()
{
$cleaned = t h i s − > c l e a n C o n t e n t s ( this->cleanContents( this>cleanContents(this->cache);

    return json_encode([$cleaned, $this->complete, $this->expire]);
}

这里我们只需要将complete赋值为我们的一句话木马,也就实现了我们的写马操作

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YY13172

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值