filter

yii+phar

题目的Tips:

据说这是配置文件里面的重要内容,或许对你有用!!

        'log' => [
            'traceLevel' => YII_DEBUG ? 0 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'logVars' => [],
                ],
            ],
        ],

看SiteController.php相较于原yii源码,只修改了一处地方。

    public function actionIndex()
    {
        $file = Yii::$app->request->get('file');
        $res = file_get_contents($file);
        file_put_contents($file,$res);
        return $this->render('index');
    }

看一下逻辑,通过GET方式获取file变量,将$file通过file_get_contents读取到$res,并通过file_put_contents再写回文件。看起来只是一个来回读写文件的操作,实际上可以用文件操作函数phar伪协议进行反序列化。

接着看composer.json,我这里拿的是2.0.37的yii2,compare后只有一处不同,于是猜测版本,以及固有的反序列化漏洞。

发现多了一行

而这个版本存在RCE漏洞,看一下phpggc的monolog/RCE1:

用phpggc生成exp:

清空日志文件:

写入日志,注意最后加上个字符a

保留phar的内容

最后用phar协议打一下

exp:

Last updated