时间: 2020-10-11|tag: 19次围观|0 条评论

已打上20140618补丁。再来试试。

在app/my_goods.app.php中

 

function spec_edit()
{
 $id = isset($_GET['id'])? intval($_GET['id']):0;
if(!IS_POST)
{
 $goods_spec = $this->_goods_mod->findAll(array(
'fields'=>"this.goods_name,this.goods_id,this.spec_name_1,this.spec_name_2",
'conditions'=>"goods_id = $id",
'include'=> array('has_goodsspec'=> array('order'=>'spec_id')),
));
 header('Content-Type:text/html;charset='. CHARSET);
 $this->assign('goods', current($goods_spec));
 $this->display("spec_edit.html");
}
else
{
 $data = $this->save_spec($_POST);
if(empty($data))
{
 $this->pop_warning('not_data');
}
 $default_spec = array();// 更新商品中默认规格的信息
foreach($data as $key => $val)
{
if(empty($default_spec))
{
 $default_spec = array('price'=> $val['price']);
}
 $this->_spec_mod->edit($key, $val);
}
 $this->_goods_mod->edit($id, $default_spec);
 $this->pop_warning('ok','my_goods_spec_edit');
}
}

 

来看看这个 $data = $this->save_spec($_POST);

 

function save_spec($spec)
{
 $data = array();
if(empty($spec['price'])|| empty($spec['stock']))
{
return $data;
}
foreach($spec['price']as $key => $val)
{
 $data[$key]['price']= $this->_filter_price($val);
}
foreach($spec['stock']as $key => $val)
{
 $data[$key]['stock']= intval($val);
}
return $data;
}

 

这里return的是data。 在这里 $spec['stock'] 被intval了。
$data[$key]['price'] = $this->_filter_price($val);

 

function _filter_price($price)
{
return abs(floatval($price));
}
}

返回非浮点 。 所以这里data的value 是不可控的 但是 key是可控的 继续看。
 

foreach($data as $key => $val)
{
if(empty($default_spec))
{
 $default_spec = array('price'=> $val['price']);
}
 $this->_spec_mod->edit($key, $val);
}

 

key 带入到了edit中 继续看

 

function edit($conditions, $edit_data)
{
if(empty($edit_data))
{
returnfalse;
}
 $edit_data = $this->_valid($edit_data);
if(!$edit_data)
{
returnfalse;
}
 $edit_fields = $this->_getSetFields($edit_data);
 $conditions = $this->_getConditions($conditions,false);
 $this->db->query("UPDATE {$this->table} SET {$edit_fields}{$conditions}");
return $this->db->affected_rows();

 

拼语句。 直接注入。 

在618补丁中还加入放注入的了。

但是还是勉强能过。 

首先注册一个会员 然后发布一个商品。

Ecmall Sql 注入 第二弹 – 网站安全 – 自学php插图

修复方案:

限制一下key把。 

    上一篇: 芒果云KODExlporer设计缺陷导致任意代码执行 - 网站

    下一篇: PageAdmin任意文件删除+注册管理员 - 网站安全 - 自
本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《Ecmall Sql 注入 第二弹 – 网站安全 – 自学php
   

还没有人抢沙发呢~