Lucene search

K
seebugRootSSV:93524
HistoryOct 09, 2011 - 12:00 a.m.

ECShop 2.7.2 红包注入漏洞

2011-10-0900:00:00
Root
www.seebug.org
11

简要描述:

flow.php页面看似intval的红包ID,其实可以注入。以下文章仅从代码推测,并未进行测试,不过这太明显了,就不测试了,各位看官测试失败请跟帖骂娘,死亡节奏技术小组、恶灵战队路过。

详细说明:


/flow.php 1168行开始

$bonus = bonus_info(intval($_GET['bonus']));
        if ((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || $_GET['bonus'] == 0)
        {
            $order['bonus_id'] = $_GET['bonus'];
        }
        else
        {
            $order['bonus_id'] = 0;
            $result['error'] = $_LANG['invalid_bonus'];
        }
        /* 计算订单的费用 */
        $total = order_fee($order, $cart_goods, $consignee);

$bonus = bonus_info(intval($_GET[‘bonus’]));
上面这一句貌似把$_GET[‘bonus’]给变整形了,没错,这句话没问题,继续向下看,

if ((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || $_GET['bonus'] == 0)
        {
            $order['bonus_id'] = $_GET['bonus'];
        }

上面代码显示:如果通过GET来的红包ID获取到红包信息并且红包属于你,
就执行下面这句

$order['bonus_id'] = $_GET['bonus'];

看到没有,这里$order[‘bonus_id’]就获得了一个没有过滤的红包ID,
然后
下面这句

/* 计算订单的费用 */
        $total = order_fee($order, $cart_goods, $consignee);

未经过滤的红包ID进入了order_fee函数,来看看这个函数的代码(在/includes/lib_order.php中),

function order_fee($order, $goods, $consignee)
{
//.....省略若干行,来到643行,
 if (!empty($order['bonus_id']))
    {
        $bonus          = bonus_info($order['bonus_id']);
        $total['bonus'] = $bonus['type_money'];
    }
}

未经过滤的红包ID再次进入bonus_info函数,这个函数也是在上面的这个文件里,
来到1408行

function bonus_info($bonus_id, $bonus_sn = '')
{
    $sql = "SELECT t.*, b.* " .
            "FROM " . $GLOBALS['ecs']->table('bonus_type') . " AS t," .
                $GLOBALS['ecs']->table('user_bonus') . " AS b " .
            "WHERE t.type_id = b.bonus_type_id ";
    if ($bonus_id > 0)
    {
        $sql .= "AND b.bonus_id = '$bonus_id'";
    }
    else
    {
        $sql .= "AND b.bonus_sn = '$bonus_sn'";
    }
    return $GLOBALS['db']->getRow($sql);
}

恰好,字符串大于0,因此注入字符串可以顺利进入SQL,好了,恭喜发财,rank值多给点

漏洞证明:

就不证明,自己看代码