### 简要描述: 来一发..... ### 详细说明: 齐博官网下载第一栏的最新版b2b商务系统作测试。 [<img src="https://images.seebug.org/upload/201510/07160933fc2cef61130a3c2ca2fc432e4b156754.png" alt="QQ截图20151007160935.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07160933fc2cef61130a3c2ca2fc432e4b156754.png) 环境:win7+xampp php 以普通用户权限注册一个号 账号为test 目标取得后台admin权限(Cookies) 在会员中心右栏发表文章,文章发表栏任意~~ [<img src="https://images.seebug.org/upload/201510/07161311fe29bfe55fab09719e7ac60a02be4490.png" alt="QQ截图20151007161205.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07161311fe29bfe55fab09719e7ac60a02be4490.png) 填完数据后提交, burp抓包,改postdb[content]栏,如图 [<img src="https://images.seebug.org/upload/201510/07163449603e97e6a5efe2730928ca49487da6af.png" alt="QQ截图20151007163415.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07163449603e97e6a5efe2730928ca49487da6af.png) 提交。 ### 漏洞证明:...
### 简要描述: 来一发..... ### 详细说明: 齐博官网下载第一栏的最新版b2b商务系统作测试。 [<img src="https://images.seebug.org/upload/201510/07160933fc2cef61130a3c2ca2fc432e4b156754.png" alt="QQ截图20151007160935.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07160933fc2cef61130a3c2ca2fc432e4b156754.png) 环境:win7+xampp php 以普通用户权限注册一个号 账号为test 目标取得后台admin权限(Cookies) 在会员中心右栏发表文章,文章发表栏任意~~ [<img src="https://images.seebug.org/upload/201510/07161311fe29bfe55fab09719e7ac60a02be4490.png" alt="QQ截图20151007161205.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07161311fe29bfe55fab09719e7ac60a02be4490.png) 填完数据后提交, burp抓包,改postdb[content]栏,如图 [<img src="https://images.seebug.org/upload/201510/07163449603e97e6a5efe2730928ca49487da6af.png" alt="QQ截图20151007163415.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07163449603e97e6a5efe2730928ca49487da6af.png) 提交。 ### 漏洞证明: 因为默认文章需要后台审核后才能发布,用admin登陆后台审核文章。 [<img src="https://images.seebug.org/upload/201510/07162454609e13bf63689719d1c408467971c8c3.png" alt="QQ截图20151007162140.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07162454609e13bf63689719d1c408467971c8c3.png) [<img src="https://images.seebug.org/upload/201510/07162506fe9aa45ac34c56f558498ccd3ed3cbb4.png" alt="QQ截图20151007162438.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07162506fe9aa45ac34c56f558498ccd3ed3cbb4.png) [<img src="https://images.seebug.org/upload/201510/07163609330457d885d71f870f652fa7c306f0a3.png" alt="QQ截图20151007163624.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07163609330457d885d71f870f652fa7c306f0a3.png) 执行了脚本,得到有效cookie~~~ content内长度是够了。 看看代码问题在哪儿 \news\member\post.php 154-165行 ``` $postdb[content] = get_outpic($postdb[content],$fid,$GetOutPic); $postdb[content] = En_TruePath($postdb[content]); $postdb[content] = preg_replace('/javascript/i','java script',$postdb[content]);//过滤js代码 $postdb[content] = preg_replace('/<iframe ([^<>]+)>/i','<iframe \\1>',$postdb[content]);//过滤框架代码 foreach($postdb AS $key=>$value){ if($key=='content'){ continue; //为啥要continue } $postdb[$key]=filtrate($value); } ``` foreach中看到key为content就放弃filtrate了,且上面的正则根没过滤一样=。=。看看filtrate() ``` function filtrate($msg){ //$msg = str_replace('&','&',$msg); //$msg = str_replace(' ',' ',$msg); $msg = str_replace('"','"',$msg); $msg = str_replace("'",''',$msg); $msg = str_replace("<","<",$msg); $msg = str_replace(">",">",$msg); $msg = str_replace("\t"," ",$msg); //$msg = str_replace("\r","",$msg); $msg = str_replace(" "," ",$msg); return $msg; } ``` 依然没过滤 '<' '>' 等危险代码,程序猿写一个吧~~~ xss2: 进入test用户的用户中心。 [<img src="https://images.seebug.org/upload/201510/07165336218793d5ae76ddd7599674c51baf3aea.png" alt="QQ截图20151007164834.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07165336218793d5ae76ddd7599674c51baf3aea.png) 写新信息 接受者为admin(默认后台用户名) [<img src="https://images.seebug.org/upload/201510/071655048d636e5909a77e55b1c37403e04ea39c.png" alt="QQ截图20151007165528.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/071655048d636e5909a77e55b1c37403e04ea39c.png) 填完,burp抓包,改postdb[content]栏 如图 [<img src="https://images.seebug.org/upload/201510/071707134a7758985709b4fad685d723d559462c.png" alt="QQ截图20151007170559.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/071707134a7758985709b4fad685d723d559462c.png) 提交 用admin账号进入(建站默认admin用户拥有后台前台所有权限) [<img src="https://images.seebug.org/upload/201510/07170215aabdbd2dd94b30d467467e3257df83f8.png" alt="QQ截图20151007170211.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07170215aabdbd2dd94b30d467467e3257df83f8.png) 有新消息,点击查看 [<img src="https://images.seebug.org/upload/201510/07170734f6aab92e799f73c55368b39042f23098.png" alt="QQ截图20151007170400.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07170734f6aab92e799f73c55368b39042f23098.png) [<img src="https://images.seebug.org/upload/201510/07170745434d17cfcc4cd675b6723136fca70740.png" alt="QQ截图20151007170647.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/07170745434d17cfcc4cd675b6723136fca70740.png) 有效admin cookie出来了。。。 content长度够长~~ 看代码 xss3: 直接上问题code 问题文件所在位置 \hy\bd_pics.php 5-33行 ``` function ReplaceHtmlAndJs($document) { $document = trim($document); if (strlen($document) <= 0) { return $document; } $search = array ("'<script[^>]*?>.*?</script>'si", // 去掉 javascript "'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记 "'([\r\n])[\s]+'", // 去掉空白字符 "'&(quot|#34);'i", // 替换 HTML 实体 "'&(amp|#38);'i", "'&(lt|#60);'i", //问题在这里 "'&(gt|#62);'i", "'&(nbsp|#160);'i" ); // 作为 PHP 代码运行 $replace = array ("", "", "\\1", "\"", "&", "<", //恢复了实体 ">", " " ); return @preg_replace($search, $replace, $document); } ``` 这个函数写得挺纳闷,匹配 <和>然后替换成 实体 < > ...........这不是自己给自己设个套吗!! 看看哪里调用 ReplaceHtmlAndJs 在 hy\member\post_company.php 86-88看到 ``` if(!$postdb[qy_regmoney]) showerr_post("请输入公司注册资本"); if(!$postdb[content]) showerr_post("详细商家介绍不能为空"); $postdb[content]=nl2br($postdb[content]); if(!$postdb[qy_contact_tel]) showerr_post("指定联系人电话不能为空"); if(!$postdb[qy_contact]) showerr_post("指定联系人不能为空"); if(!$postdb[qy_contact_email]) showerr_post("指定联系人邮箱地址不能为空"); foreach($postdb as $key=>$val){//全部数据处理 $postdb[$key]=ReplaceHtmlAndJs($val); //多处参数惨遭xss } if(!ereg("^[-a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,5}$",$postdb[qy_contact_email])){ showerr_post('邮箱不符合规则'); ``` 我们来利用一下打后台。 以普通注册用户身份 test登陆 然后创建商铺如图 [<img src="https://images.seebug.org/upload/201510/08230055dd482504afe90f6bf48e272608957322.png" alt="QQ截图20151008225932.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/08230055dd482504afe90f6bf48e272608957322.png) 随便填一下参数,我们的目标是打后台。提交后burp抓包,修改postdb[title]参数 如下图 [<img src="https://images.seebug.org/upload/201510/08230600d6f786f57363e16863a1973c539084fd.png" alt="QQ截图20151008230409.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/08230600d6f786f57363e16863a1973c539084fd.png) 查看发布情况可以发现存在前台xss 如下图 [<img src="https://images.seebug.org/upload/201510/0823080482313a417cf78c413a7e95778caf1030.png" alt="QQ截图20151008230753.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/0823080482313a417cf78c413a7e95778caf1030.png) 那么怎么打后台呢, 我们用admin进后台 黄页店铺->店铺管理 即可 如下图 [<img src="https://images.seebug.org/upload/201510/0823111729ed3b9025cb9df7ee5710bad3d958bc.png" alt="QQ截图20151008230958.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/0823111729ed3b9025cb9df7ee5710bad3d958bc.png) [<img src="https://images.seebug.org/upload/201510/08231126aa43a7b233394134278fe01e69486014.png" alt="QQ截图20151008231105.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201510/08231126aa43a7b233394134278fe01e69486014.png) 打到有效admin cookie 且长度为限制~