问题详情描述:
在Discuz中,uc_key是UC客户端与服务端通信的通信密钥,discuz中的/api/uc.php存在代码写入漏洞,导致黑客可写入恶意代码获取uckey,最终进入网站后台,造成数据泄漏。您也可以登录官方网站更新到最新版本解决。
解决方法:
打开/api/uc.php
找到- if(!API_UPDATEBADWORDS) {
- return API_RETURN_FORBIDDEN;
- }
- $data = array();
- if(is_array($post)) {
- foreach($post as $k => $v) {
- if(substr($v['findpattern'], 0, 1) != '/' || substr($v['findpattern'], -3) != '/is') {
- $v['findpattern'] = '/' . preg_quote($v['findpattern'], '/') . '/is';
- }
- $data['findpattern'][$k] = $v['findpattern'];
- $data['replace'][$k] = $v['replacement'];
- }
- }
复制代码 修改为
- if(!API_UPDATEBADWORDS) {
- return API_RETURN_FORBIDDEN;
- }
- $data = array();
- if(is_array($post)) {
- foreach($post as $k => $v) {
- //dz uc-key修改开始
- if(substr($v['findpattern'], 0, 1) != '/' || substr($v['findpattern'], -3) != '/is') {
- $v['findpattern'] = '/' . preg_quote($v['findpattern'], '/') . '/is';
- }
- //end 修改结束
- $data['findpattern'][$k] = $v['findpattern'];
- $data['replace'][$k] = $v['replacement'];
- }
- }
复制代码 第二处修改
找到- function updateapps($get, $post) {
- global $_G;
- if(!API_UPDATEAPPS) {
- return API_RETURN_FORBIDDEN;
- }
- $UC_API = '';
- if($post['UC_API']) {
- $UC_API = str_replace(array('\'', '"', '\\', "\0", "\n", "\r"), '', $post['UC_API']);
- unset($post['UC_API']);
- }
- $cachefile = DISCUZ_ROOT.'./uc_client/data/cache/apps.php';
复制代码 修改为
- function updateapps($get, $post) {
- global $_G;
- if(!API_UPDATEAPPS) {
- return API_RETURN_FORBIDDEN;
- }
- //$UC_API = $post['UC_API'];
- //dz uc-key修改开始
- $UC_API = '';
- if($post['UC_API']) {
- $UC_API = str_replace(array('\'', '"', '\\', "\0", "\n", "\r"), '', $post['UC_API']);
- unset($post['UC_API']);
- }
- //end修改结束
- $cachefile = DISCUZ_ROOT.'./uc_client/data/cache/apps.php';
复制代码 第三处修改
找到
- $configfile = preg_replace
复制代码 修改为- $configfile = preg_replace("/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '".addslashes($UC_API)."');", $configfile);
复制代码
|