74cms 最新版 注入4-7

2014-06-02T00:00:00
ID SSV:94099
Type seebug
Reporter Root
Modified 2014-06-02T00:00:00

Description

简要描述:

Check it over.

详细说明:

74cms 为了防止宽字节注入 设置了二进制读取 但是却没有在一些转换编码的地方做好安全 并且过滤也不完善。

function remove_xss($string) { $string = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $string); $parm1 = Array('javascript', 'vbscript', 'expression', 'applet', 'union', 'xml', 'blink', 'link', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $parm2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); $parm = array_merge($parm1, $parm2); for ($i = 0; $i < sizeof($parm); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($parm[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[x|X]0([9][a][b]);?)?'; $pattern .= '|(&#0([9][10][13]);?)?'; $pattern .= ')?'; } $pattern .= $parm[$i][$j]; } $pattern .= '/i'; $string = preg_replace($pattern, '', $string); } return $string; }

开启了/i修正符 不能大小写绕过 但是这里是清空 所以ununionion绕过。


錦 从utf-8转换成gbk 为 %e5%5c 单引号被转义后\' ->%5C %e5%5c%5c%27 \ 闭合 第一处 在plus/ajax_user.php中 注册的时候

elseif ($act=='do_reg') { $captcha=get_cache('captcha'); if ($captcha['verify_userreg']=="1") { $postcaptcha=$_POST['postcaptcha']; if ($captcha['captcha_lang']=="cn" && strcasecmp(QISHI_DBCHARSET,"utf8")!=0) { $postcaptcha=iconv("utf-8",QISHI_DBCHARSET,$postcaptcha); } if (empty($postcaptcha) || empty($_SESSION['imageCaptcha_content']) || strcasecmp($_SESSION['imageCaptcha_content'],$postcaptcha)!=0) { exit("err"); } } require_once(QISHI_ROOT_PATH.'include/fun_user.php'); $username = isset($_POST['username'])?trim($_POST['username']):exit("err"); $password = isset($_POST['password'])?trim($_POST['password']):exit("err"); $member_type = isset($_POST['member_type'])?intval($_POST['member_type']):exit("err"); $email = isset($_POST['email'])?trim($_POST['email']):exit("err"); if (strcasecmp(QISHI_DBCHARSET,"utf8")!=0) { $username=iconv("utf-8",QISHI_DBCHARSET,$username);//转编码 $password=iconv("utf-8",QISHI_DBCHARSET,$password); } $register=user_register($username,$password,$member_type,$email);

function user_register($username,$password,$member_type=0,$email,$uc_reg=true) { global $db,$timestamp,$_CFG,$online_ip,$QS_pwdhash; $member_type=intval($member_type); $ck_username=get_user_inusername($username); $ck_email=get_user_inemail($email);

function get_user_inusername($username) { global $db; $sql = "select * from ".table('members')." where username = '{$username}' LIMIT 1"; return $db->getone($sql); }

带入到了查询当中 造成了注入。

<img src="https://images.seebug.org/upload/201406/02142258dfbd4fae58405e13123f3a75c317b38d.jpg" alt="73.jpg" width="600" onerror="javascript:errimg(this);">

第二处 依旧这文件 plus/ajax_user.php

elseif($act =='check_usname') { require_once(QISHI_ROOT_PATH.'include/fun_user.php'); $usname=trim($_POST['usname']); if (strcasecmp(QISHI_DBCHARSET,"utf8")!=0) { $usname=iconv("utf-8",QISHI_DBCHARSET,$usname); } $user=get_user_inusername($usname); empty($user)?exit("true"):exit("false"); }

转换编码后带入到了 get_user_inusername

function get_user_inusername($username) { global $db; $sql = "select * from ".table('members')." where username = '{$username}' LIMIT 1"; return $db-&gt;getone($sql); }

这个不多说了。。 第三处依旧这文件 plus/ajax_user.php

elseif($act == 'check_email') { require_once(QISHI_ROOT_PATH.'include/fun_user.php'); $email=trim($_POST['email']); if (strcasecmp(QISHI_DBCHARSET,"utf8")!=0) { $email=iconv("utf-8",QISHI_DBCHARSET,$email); } $user=get_user_inemail($email); empty($user)?exit("true"):exit("false"); }

function get_user_inemail($email) { global $db; return $db-&gt;getone("select * from ".table('members')." where email = '{$email}' LIMIT 1"); }

都没检测email是否合法就带入到了查询当中 造成了注入。


第四处 在plus/ajax_street.php中

elseif($act == 'key') { $key=trim($_GET['key']); if (!empty($key)) { if (strcasecmp(QISHI_DBCHARSET,"utf8")!=0) $key=iconv("utf-8",QISHI_DBCHARSET,$key); $result = $db-&gt;query("select * from ".table('category')." where c_alias='QS_street' AND c_name LIKE '%{$key}%' "); while($row = $db-&gt;fetch_array($result)) { if ($listtype=="li") { $htm.="&lt;li title=\"{$row['c_name']}\" id=\"{$row['c_id']}\"&gt;{$row['c_name']}&lt;/li&gt;"; }

转换编码后 带入到了查询当中

漏洞证明:

<img src="https://images.seebug.org/upload/201406/02143003f3c3b1b2e4af1cae0b453a8000ac7407.jpg" alt="74.jpg" width="600" onerror="javascript:errimg(this);">

测试一下demo demo上还有安全狗。。 不过轻松绕过。

<img src="https://images.seebug.org/upload/201406/021431248210fe25da1017d5bf848c949950d614.jpg" alt="75.jpg" width="600" onerror="javascript:errimg(this);">