这几天阿里频繁提醒网站有漏洞,搞得我不胜其烦,好吧,我修复还不行吗?搜索之后整理如下,仅供参考(5.7以上版本适用):
任意文件上传漏洞修复
一、/include/dialog/select_soft_post.php文件,搜索(大概在72行左右)
$fullfilename = $cfg_basedir.$activepath.'/'.$filename;
修改为
if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)[^a-zA-Z0-9]+$#i', trim($filename))) { ShowMsg("你指定的文件名被系统禁止!",'javascript:;'); exit(); } $fullfilename = $cfg_basedir.$activepath.'/'.$filename;
(SQL)注入漏洞修复
一、 /include/filter.inc.php文件,搜索(大概在46行左右)
return $svar;
修改为
return addslashes($svar);
二、/member/mtypes.php文件,搜索(大概在71行左右)
$query = "UPDATE `dede_mtypes` SET mtypename='$name' WHERE mtypeid='$id' AND mid='$cfg_ml->M_ID'";
修改为
$id = intval($id); $query = "UPDATE `dede_mtypes` SET mtypename='$name' WHERE mtypeid='$id' AND mid='$cfg_ml->M_ID'";
三、 /member/pm.php文件,搜索(大概在65行左右)
$row = $dsql->GetOne("SELECT * FROM `dede_member_pms` WHERE id='$id' AND (fromid='{$cfg_ml->M_ID}' OR toid='{$cfg_ml->M_ID}')");
修改为
$id = intval($id); $row = $dsql->GetOne("SELECT * FROM `dede_member_pms` WHERE id='$id' AND (fromid='{$cfg_ml->M_ID}' OR toid='{$cfg_ml->M_ID}')");
四、 /plus/guestbook/edit.inc.php文件,搜索(大概在48行左右)
$dsql->ExecuteNoneQuery("UPDATE `UPDATE `dede_guestbook` SET `msg`='$msg', `posttime`='".time()."' WHERE id='$id' ");
修改为
$msg = addslashes($msg); $dsql->ExecuteNoneQuery("UPDATE `UPDATE `dede_guestbook` SET `msg`='$msg', `posttime`='".time()."' WHERE id='$id' ");
五、 /plus/search.php文件,搜索(大概在70行左右)
$keyword = addslashes(cn_substr($keyword,30));
修改为
$typeid = intval($typeid); $keyword = addslashes(cn_substr($keyword,30));
其实,如果有些文件你网站用不到,不如直接删除来得简单,文件都没了,漏洞在哪?哈哈!