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

适用全部用UC整合php

阿里云提示漏洞:api

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

 

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


补丁文件:/api/uc.php

补丁来源:云盾自研阿里云

 

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

spa

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

大概216行,替换成如下:code

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

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

 

 

 

 


 科普一下:PHP addslashes() 函数ci


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

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

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

相关文章
相关标签/搜索