阿里云提示Discuz uc.key泄露导致代码注入漏洞uc.php的解决方法

适用所有用UC整合

阿里云提示漏洞:

discuz中的/api/uc.php存在代码写入漏洞,导致黑客可写入恶意代码获取uckey,..........

 

漏洞名称:Discuz uc.key泄露导致代码注入漏洞


补丁文件:/api/uc.php

补丁来源:云盾自研

 

解决方法:
找到文件/api/uc.php​ 中的以下代码:

$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;

大概216行,替换成以下:

$configfile = preg_replace("/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '".addslashes($UC_API)."');", $configfile);

更新代码后,在阿里云后台这条漏洞后面点“验证一下”,即可看到这条漏洞补上就没有了

 

 

 

 


 科普一下:PHP addslashes() 函数


 在每个双引号(")前添加反斜杠:

<?php 
$str = addslashes('Shanghai is the "biggest" city in China.');
echo($str); 
?> 

结果:Shanghai is the \"biggest\" city in China.

 

posted @ 2016-12-13 09:51  James2019  阅读(5503)  评论(0编辑  收藏  举报