jojuniori
5/4/2017 - 6:55 AM

http://blog.sina.com.cn/s/blog_3eba8f1c0102xhf3.html

文件路径:bbs/api/uc.php

修复方式:
1. 查找 updatebadwords 函数:
function updatebadwords($get, $post){
    // ...
    // 添加: 约241行    
    // Discuz uc.key泄露导致代码注入漏洞 
    if(substr($v['findpattern'], 0, 1) != '/' || substr($v['findpattern'], -3) != '/is') { 
        $v['findpattern'] = '/' . preg_quote($v['findpattern'], '/') . '/is'; 
    }
    // -- end : 2016-08-22 --
    
    $data['findpattern'][$k] = $v['findpattern'];
    // ...
}

2. 查找 updateapps 函数:
function updateapps($get, $post) {
    // ...
    // 修改: 约280行 
    $UC_API = '';
    if($post['UC_API']) {
        // $UC_API = $post['UC_API']; // 注释
        $UC_API = str_replace(array('\'', '"', '\\', "\0", "\n", "\r"), '', $post['UC_API']);
        unset($post['UC_API']);
    }
    // ...
}

3. 查找 $configfile 
注释 $configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
添加 $configfile = preg_replace("/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '".addslashes($UC_API)."');", $configfile);