网站地图    收藏   

主页 > 入门引导 > 黑客攻防 >

DedeCMS最新版前台SQL注射及修复 - 网站安全 - 自学

来源:自学PHP网    时间:2015-04-15 15:00 作者: 阅读:

[导读] 又见SQL注射,一个小问题引发的多处血案 DedeCMS在注册时对用户名、电子邮箱等限制的很死,唯独对用户笔名没做限制,可填写单引号等,由此导致再次使用笔名入库时二次注入1 member...

又见SQL注射,一个小问题引发的多处血案...
 
DedeCMS在注册时对用户名、电子邮箱等限制的很死,唯独对用户笔名没做限制,可填写单引号等,由此导致再次使用笔名入库时二次注入
 
 
 
1. /member/reg_new.php 约194行
 
$inQuery = "INSERT INTO `detest_member` (`mtype` ,`userid` ,`pwd` ,`uname` ,`sex` ,`rank` ,`money` ,`email` ,`scores` ,

        `matt`, `spacesta` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip` )

       VALUES ('$mtype','$userid','$pwd','$uname','$sex','10','$dfmoney','$email','$dfscores',

       '0','$spaceSta','','$safequestion','$safeanswer','$jointime','$joinip','$logintime','$loginip'); "; //在此之前没有对$uname做判断,可注入单引号

        if($dsql->ExecuteNoneQuery($inQuery))

 

 
 
 
 
2. 全局搜索M_UserName,username,getUserName()等,找到将笔名再次入库的点,如/include/memberlogin.class.php 约567行
 
function RecordFeeds($type, $title, $note, $aid)

    {

        global $dsql,$cfg_mb_feedcheck;

        //确定是否需要记录

        if (in_array($type,array('add','addsoft','feedback','addfriends','stow'))){

            $ntime = time();

            $title = htmlspecialchars(cn_substrR($title,255));

            if(in_array($type,array('add','addsoft','feedback','stow')))

            {

                $rcdtype = array('add'=>' 成功发布了', 'addsoft'=>' 成功发布了软件',

                                 'feedback'=>' 评论了文章','stow'=>' 收藏了');

                //内容发布处理

                $arcrul = " <a href='/plus/view.php?aid=".$aid."'>".$title."</a>";

                $title = htmlspecialchars($rcdtype[$type].$arcrul, ENT_QUOTES);

            } else if ($type == 'addfriends')

            {

                //添加好友处理

                $arcrul = " <a href='/member/index.php?uid=".$aid."'>".$aid."</a>";

                $title = htmlspecialchars(' 与'. $arcrul."成为好友", ENT_QUOTES);

            }

            $note = Html2Text($note);

            $aid = (isset($aid) && is_numeric($aid) ? $aid : 0);

            $ischeck = ($cfg_mb_feedcheck == 'Y')? 0 : 1;

            $query = "INSERT INTO `detest_member_feed` (`mid`, `userid`, `uname`, `type`, `aid`, `dtime`,`title`, `note`, `ischeck`) 

                        Values('$this->M_ID', '$this->M_LoginID', '$this->M_UserName', '$type', '$aid', '$ntime', '$title', '$note', '$ischeck'); "; //插入用户动态,这里是重点,直接使用了$this->M_UserName

            $rs = $dsql->ExecuteNoneQuery($query);

            return $rs;

        } else {

            return FALSE;

        }

 

 
3. 通过一些可记录feed的操作,如发表文章,加好友等,即可触发此注入
 
1. 注入新用户,插入sql语句(根据自己爱好写吧,最好结尾加\,然后找到可控的临近字段)
 
 
2. 加个好友,触发用户动态记录
 
3. 到个人中心看看吧~


修复方案:
在注册时就限制好笔名的格式最简单

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论