適用所有用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.