ECSHOP漏洞汇总-漏洞修改记录
更新时间:2017-03-23 点击量:6174
修改:api/client/includes/lib_api.php
function API_UserLogin($post) { if(get_magic_quotes_gpc()){ $post['UserId']=$post['UserId']; }else{ $post['UserId']=addslashes($post['UserId']); } $post['username'] = isset($post['UserId']) ? trim($post['UserId']) : ''; $post['password'] = isset($post['Password']) ? strtolower(trim($post['Password'])) : ''; /* 检查密码是否正确 */ $sql = "SELECT user_id, user_name, password, action_list, last_login". " FROM " . $GLOBALS['ecs']->table('admin_user') . " WHERE user_name = '" . htmlspecialchars($post['username']). "'";//对用户名进行简单过滤 $row = $GLOBALS['db']->getRow($sql);
2.跨站攻击
www.aaa.com/mobile/buy.php?id=849<body+onload=prompt()>
在includes/init.php中引入阿里云通用漏洞补丁文件,waf.php。
require(ROOT_PATH . 'includes/waf.php');
并加以修改:
else //购物车没有此物品,则插入 { $goods_price = get_final_price($goods_id, $num, true, $spec); $parent['goods_price'] = max($goods_price, 0); $parent['goods_number'] = $num; $parent['parent_id'] = 0; $sql = "SELECT * FROM " .$GLOBALS['ecs']->table('cart'). " WHERE goods_id = '$goods_id' "; $hasgoods = $GLOBALS['db']->query($sql); if(empty($hasgoods)){ $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('cart'), $parent, 'INSERT'); }else{ echo "该商品已经存在!";exit; } } }
如果不修改lib_order.php文件,跨站攻击虽然阻止了,但是数据库错误语句会暴露!
3.
ECSHOP的配送地址页面网页没有验证地区参数的有效性,存在sql注入漏洞,攻击者可利用火狐tamper data等插件修改提交到配送地址页面的post数据,造成未授权的数据库操作甚至执行任意代码。
修改:flow.php
/* 保存收货人信息 */ $consignee = array( 'address_id' => empty($_POST['address_id']) ? 0 : intval($_POST['address_id']), 'consignee' => empty($_POST['consignee']) ? '' : trim(htmlspecialchars($_POST['consignee'])), 'country' => empty($_POST['country']) ? '' : intval($_POST['country']), 'province' => empty($_POST['province']) ? '' : intval($_POST['province']), 'city' => empty($_POST['city']) ? '' : intval($_POST['city']), 'district' => empty($_POST['district']) ? '' : intval($_POST['district']), 'email' => empty($_POST['email']) ? '' : htmlspecialchars($_POST['email']), 'address' => empty($_POST['address']) ? '' : htmlspecialchars($_POST['address']), 'zipcode' => empty($_POST['zipcode']) ? '' : make_semiangle(trim(htmlspecialchars($_POST['zipcode']))), 'tel' => empty($_POST['tel']) ? '' : make_semiangle(trim(htmlspecialchars($_POST['tel']))), 'mobile' => empty($_POST['mobile']) ? '' : make_semiangle(trim(htmlspecialchars($_POST['mobile']))), 'sign_building' => empty($_POST['sign_building']) ? '' : htmlspecialchars($_POST['sign_building']), 'best_time' => empty($_POST['best_time']) ? '' : htmlspecialchars($_POST['best_time']), ); 使用htmlspecialchars不能消除漏洞, $consignee = array( 'address_id' => empty($_POST['address_id']) ? 0 : intval($_POST['address_id']), 'consignee' => empty($_POST['consignee']) ? '' : compile_str(trim($_POST['consignee'])), 'country' => empty($_POST['country']) ? '' : intval($_POST['country']), 'province' => empty($_POST['province']) ? '' : intval($_POST['province']), 'city' => empty($_POST['city']) ? '' : intval($_POST['city']), 'district' => empty($_POST['district']) ? '' : intval($_POST['district']), 'email' => empty($_POST['email']) ? '' : compile_str($_POST['email']), 'address' => empty($_POST['address']) ? '' : compile_str($_POST['address']), 'zipcode' => empty($_POST['zipcode']) ? '' : compile_str(make_semiangle(trim($_POST['zipcode']))), 'tel' => empty($_POST['tel']) ? '' : compile_str(make_semiangle(trim($_POST['tel']))), 'mobile' => empty($_POST['mobile']) ? '' : compile_str(make_semiangle(trim($_POST['mobile']))), 'sign_building' => empty($_POST['sign_building']) ? '' : compile_str($_POST['sign_building']), 'best_time' => empty($_POST['best_time']) ? '' : compile_str($_POST['best_time']), );
4.
ecshop的后台编辑文件/admin/affiliate_ck.php中,对输入参数auid未进行正确类型转义,导致整型注入的发生。
修改:affiliate_ck.php
if (!empty($_GET['auid'])) { $smarty->assign('action_link', array('text' => $_LANG['back_note'], 'href'=>"users.php?act=edit&id=intval($_GET[auid])"));//注:该处auid需要用单引号包围 } if (isset($_GET['auid'])) { $sqladd = ' AND a.user_id=' . intval($_GET['auid']); }
5.
ecshop的后台编辑文件/admin/shophelp.php中,对输入参数$_POST['id']未进行正确类型转义,导致整型注入的发生。
修改:shophelp.php
/* 取得文章数据 */ $sql = "SELECT article_id, title, content FROM ".$ecs->table('article')."WHERE article_id =".intval($_REQUEST['id']); $article = $db->GetRow($sql); /* 检查重名 */ if ($_POST['title'] != $_POST['old_title']) { $is_only = $exc->is_only('title', htmlspecialchars($_POST['title']), intval($_POST['id'])); if (!$is_only) { sys_msg(sprintf($_LANG['title_exist'], stripslashes($_POST['title'])), 1); } } /* 更新数据 */ $cur_time = gmtime(); if ($exc->edit("title='$_POST[title]', content='$_POST[FCKeditor1]',add_time ='$cur_time'",intval($_POST['id']))) { /* 清除缓存 */ clear_cache_files(); /* 取文章数据 */ $sql = "SELECT article_id,title, cat_id, article_type, is_open, author, author_email, keywords, content FROM " .$ecs->table('article'). " WHERE article_id=intval($_REQUEST['id'])";
6.
ecshop的/admin/comment_manage.php中,对输入参数sort_by、sort_order未进行严格过滤,导致SQL注入
修改:comment_manage.php
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'add_time' : trim(htmlspecialchars($_REQUEST['sort_by'])); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim(htmlspecialchars($_REQUEST['sort_order']));
7.
ECShop存在一个盲注漏洞,问题存在于/api/client/api.php文件中,提交特制的恶意POST请求可进行SQL注入攻击,可获得敏感信息或操作数据库。
修改:api/client/includes/lib_api.php
* 用户登录函数 * 验证登录,设置COOKIE * * @param array $post */ function API_UserLogin($post) { $post['username'] = isset($post['UserId']) ? trim(htmlspecialchars($post['UserId'])) : '';
8.
ECSHOP支付插件存在SQL注入漏洞,此漏洞存在于/includes/modules/payment/alipay.php文件中,该文件是ECshop的支付宝插件。由于ECShop使用了str_replace函数做字符串替换,黑客可绕过单引号限制构造SQL注入语句。只要开启支付宝支付插件就能利用该漏洞获取网站数据,且不需要注册登入。
修改:alipay.php
$order_sn = str_replace($_GET['subject'], '', $_GET['out_trade_no']); $order_sn = trim($order_sn); $len = strlen($_GET['subject']); $t_subject = substr ($_GET['out_trade_no'], 0, $len); //$order_sn = substr ($_GET['out_trade_no'], $len); if ($t_subject != $_GET['subject']) { $order_sn = $_GET['out_trade_no']; } /** * end */ //$order_sn = trim($order_sn);
如果文章对您有帮助,就打赏一个吧