代理加盟

2023全新代理计划,一站式模板建站,铜牌代理低至699元送终身VIP,独立代理后台,自营贴牌。

您现在的位置: 麦站网 > 织梦大学 > 织梦安全 >

最新织梦cms漏洞之安全设置,有效防护木马(更新至20190920)(2)

来源:本站原创 发布时间:2021-06-21 11:53:24热度:我要评论(2

麦站模板建站平台(10年经验),服务数万家企业,固定透明报价。域名注册、主机/服务器、网站源码一站式服务。实体公司,专业团队,值得选择!超过1000套模板已登记版权,合规合法建站,规避版权风险!【点击获取方案】

安全设置五:任意文件上传漏洞

①、漏洞文件① /include/dialog/select_soft_post.php

$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;

②、漏洞文件 /dede/media_add.php

这是后台文件任意上传漏洞(上面有说删除此文件,如果不删除,需要使用这个功能,那么修改以下代码补掉漏洞)

$fullfilename = $cfg_basedir.$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.$filename;

③、漏洞文件 /include/uploadsafe.inc.php (修改两个地方)

$image_dd = @getimagesize($$_key);
修改为
$image_dd = @getimagesize($$_key); if($image_dd == false){ continue; }

 

${$_key.'_size'} = @filesize($$_key);}
修改为
${$_key.'_size'} = @filesize($$_key);}
$imtypes = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp", "image/bmp"); 
if(in_array(strtolower(trim(${$_key.'_type'})), $imtypes)) { $image_dd = @getimagesize($$_key); if($image_dd == false){ continue; } 
if (!is_array($image_dd)) { exit('Upload filetype not allow !');} }
 

安全设置六、SQL注入漏洞

①、漏洞文件 /include/filter.inc.php (大概在46行)

return $svar;
修改为
return addslashes($svar);


 ②、漏洞文件 /plus/search.php (大概在109行)

$keyword = addslashes(cn_substr($keyword,30));
修改为
$typeid = intval($typeid); $keyword = addslashes(cn_substr($keyword,30));

③、漏洞文件 /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 (大概在55行)

$dsql->ExecuteNoneQuery("UPDATE `dede_guestbook` SET `msg`='$msg', `posttime`='".time()."' WHERE id='$id' ");
修改为
$msg = addslashes($msg); $dsql->ExecuteNoneQuery("UPDATE `dede_guestbook` SET `msg`='$msg', `posttime`='".time()."' WHERE id='$id' ");;

⑥、漏洞文件 /member/soft_add.php (大概在154行)

$urls .= "{dede:link islocal='1' text='{$servermsg1}'} $softurl1 {/dede:link}
";
修改为     
if (preg_match("#}(.*?){/dede:link}{dede:#sim", $servermsg1) != 1) 
{ $urls .= "{dede:link islocal='1' text='{$servermsg1}'} $softurl1 {/dede:link}
"; }

⑦、漏洞文件 /member/article_add.php (大概在83行,cookies泄漏导致SQL漏洞)

if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))
修改为
if (empty($dede_fieldshash) || ( $dede_fieldshash != md5($dede_addonfields . $cfg_cookie_encode) && $dede_fieldshash != md5($dede_addonfields . 'anythingelse' . $cfg_cookie_encode))) 

⑧、漏洞文件 /member/album_add.php (大约220行,对输入参数mtypesid未进行int整型转义,导致SQL注入发生)

$description = HtmlReplace($description, -1);//2011.06.30 增加html过滤 (by:织梦的鱼)
修改为
$description = HtmlReplace($description, -1);//2011.06.30 增加html过滤 (by:织梦的鱼)
$mtypesid = intval($mtypesid);

⑨、漏洞文件 /member/inc/inc_archives_functions.php (大概在239行,cookies泄漏导致SQL漏洞)

echo "<input type="hidden" name="dede_fieldshash" value="".md5($dede_addonfields.$cfg_cookie_encode)."" />";
修改为
echo "<input type="hidden" name="dede_fieldshash" value="". md5($dede_addonfields . 'anythingelse' .$cfg_cookie_encode) ."" />";

⑩、漏洞文件 /include/common.inc.php (SESSION变量覆盖导致SQL注入漏洞,最新的版本中已经修复)

if( strlen($svar)>0 && preg_match('#^(cfg_|GLOBALS|_GET|_POST|_COOKIE)#',$svar) )
修改为
if( strlen($svar)>0 && preg_match('#^(cfg_|GLOBALS|_GET|_POST|_COOKIE|_SESSION)#',$svar) )


⑪、漏洞文件 /include/payment/alipay.php (支付模块注入漏洞,此漏洞织梦官方在最新的版本中已经修复)

$order_sn = trim($_GET['out_trade_no']);
修改为
$order_sn = trim(addslashes($_GET['out_trade_no']));

⑫、漏洞文件 /include/dedesql.class.php (大概在590行)

if(isset($GLOBALS['arrs1']))
修改为
$arrs1 = array(); $arrs2 = array(); if(isset($GLOBALS['arrs1']))

⑬、漏洞文件 /member/inc/archives_check_edit.php (大概第92行,dedecms前台任意文件删除(需要会员中心),发表文章处,对于编辑文章的时候图片参数处理不当,导致了任意文件删除)

$litpic =$oldlitpic;
修改为
$litpic =$oldlitpic; 
if (strpos( $litpic, '..') !== false || strpos( $litpic, $cfg_user_dir."/{$userid}/" ) === false) exit('not allowed path!');

安全设置五:无用文件中的风险代码删除

①  dede empletslogin_ad.htm(这是织梦默认后台登陆界面的广告代码,没用,删除以下这段代码)

<!--<script type="text/javascript" src="<?php echo UPDATEHOST;?>/dedecms/loginad.<?php echo $cfg_soft_lang; ?>.js"></script>-->
<div class="dede-ad">
  <ul>
    <script type="text/javascript"src="http://ad.dedecms.com/adsview/?action=single&key=admcploginad&charset=gbk"></script>
  </ul>
</div>

② dede empletsindex_body.htm(织梦的后台首页模板文件,删除以下这段广告代码)

<iframe name="showad" src="index_body.php?dopost=showad" frameborder="0" width="100%" id="showad" frameborder="0" scrolling="no"  marginheight="5"></iframe>

③ dedemodule_main.php(向织梦官网发送卸载或安装插件的信息,若服务器配置不高,或不支持采集(下载),那会卡死!注释掉以下代码)

SendData($hash);//321行
SendData($hash,2);//527行

④ include aglib link.lib.php(织梦官方友链上传的代码,没有用,删除,否则占用性能,甚至卡死)

else if($typeid == 999)
{
}
//将{}里的以及上面的else全部删除

⑤ includededemodule.class.php(版本检测代码,30分钟一次,要扫描文件的!为什么管理模块打不开的原因就在这里,网站配置低的,卡死!)

if(file_exists($cachefile) && (filemtime($cachefile) + 60 * 30) > time())
修改为
if(file_exists($cachefile) && filesize($cachefile) > 10)

⑥ includededesql.class.php(下面这段代码会给网站加友情链接及版权"Power by DedeCms",删除)

$arrs1 = array(0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0x62,0x79);
$arrs2 = array(0x20,0x3c,0x61,0x20,0x68,0x72,0x65,0x66,0x3d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65,0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x20,0x74,0x61,0x72,0x67,0x65,0x74,0x3d,0x27,0x5f,0x62,0x6c,0x61,0x6e,0x6b,0x27,0x3e,0x50,0x6f,0x77,0x65,0x72,0x20,0x62,0x79,0x20,0x44,0x65,0x64,0x65,0x43,0x6d,0x73,0x3c,0x2f,0x61,0x3e);

//特殊操作
$arrs1 = array(); $arrs2 = array(); if(isset($GLOBALS['arrs1']))
{
    $v1 = $v2 = '';
    for($i=0;isset($arrs1[$i]);$i++)
    {
        $v1 .= chr($arrs1[$i]);
    }
    for($i=0;isset($arrs2[$i]);$i++)
    {
        $v2 .= chr($arrs2[$i]);
    }
    $GLOBALS[$v1] .= $v2;
}

⑦ includecommon.func.php(会给网站加版权的,删除)

$arrs1 = array(0x63,0x66,0x67,0x5f,0x70,0x6f,0x77,0x65,0x72,0x62,0x79);
$arrs2 = array(0x20,0x3c,0x61,0x20,0x68,0x72,0x65,0x66,0x3d,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65,0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x20,0x74,0x61,0x72,
0x67,0x65,0x74,0x3d,0x27,0x5f,0x62,0x6c,0x61,0x6e,0x6b,0x27,0x3e,0x50,0x6f,0x77,0x65,0x72,0x20,
0x62,0x79,0x20,0x44,0x65,0x64,0x65,0x43,0x6d,0x73,0x3c,0x2f,0x61,0x3e);

转载请注明来源网址:https://www.xiuzhanwang.com/dedecms_aq/1619.html

发表评论

评论列表(条)

     
    QQ在线咨询
    VIP限时特惠