源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

phpBB 2.0.13惊现漏洞的解决

  • 时间:2021-07-26 20:30 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:phpBB 2.0.13惊现漏洞的解决
一、Path Disclosure  漏洞文件:/db/oracle.php 漏洞描叙:直接访问oracle.php,导致暴露web路径 涉及版本:phpbb <=2.013 测试:ie提交http://127.0.0.1/phpBB2/db/oracle.php 返回错误: Fatal error: Cannot redeclare sql_nextid() in f:\easyphp1-7\www\phpbb2\db\oracle.php on line 405 解决办法 如果你不是采用的oracle数据库,可以直接把oracle.php删除  修改php.ini设置: display_errors = Off  二、Remote php File Include 漏洞文件:/admin/admin_styles.php 漏洞描叙:admin_styles.php文件里变量过滤不严,导致从后台执行恶意代码,从而危险服务器安全 涉及版本:phpbb <=2.013+ php <5.0 漏洞分析: 71 case "addnew": 72 $install_to = ( isset($HTTP_GET_VARS[’install_to’]) ) ? urldecode($HTTP_GET_VARS[’install_to’]) : $HTTP_POST_VARS[’install_to’]; 73 $style_name = ( isset($HTTP_GET_VARS[’style’]) ) ? urldecode($HTTP_GET_VARS[’style’]) : $HTTP_POST_VARS[’style’]; 74  75 if( isset($install_to) ) 76 {  77 78 include($phpbb_root_path. "templates/" . $install_to . "/theme_info.cfg"); 79 80 $template_name = $install_to; 81 $found = FALSE; $install_to变量过滤不严,导致被include($phpbb_root_path. "templates/" . $install_to . "/theme_info.cfg");调用,入侵者可以通过构造 $install_to达到攻击 目的 测试分析(目的:从后台得到webshelll): 首先我们只看78行代码 78 include($phpbb_root_path. "templates/" . $install_to . "/theme_info.cfg"); include最终于是执行了theme_info.cfg文件,theme_info.cfg是保存“风格”的一些设置 如果我们可以在从在theme_info.cfg文件插入恶意代码,那么就直接通过include执行了我们的代码 :) [思路参考《从后台到webshell的一点思路》]我们来测试下: 后台风格管理-->管理选项--->编辑-->CSS 风格表 输入";phpinfo();" (也可以是其他变量插入),然后“输出”设置成功保存到theme_info.cfg文件 我们在打开theme_info.cfg看看: $subSilver[0][’head_stylesheet’] = "subSilver.css\";phpinfo();\""; 郁闷"被过滤了,我是在 magic_quotes_gpc = off 下测试的 看来phpbb本身对做了过滤 ,此路不通 :( 在对于<5.0(不包括4.10)的php本身存在对null截断的漏洞: ------------------------------- 漏洞具体描叙 start ------------------------------- PHP存在输入验证漏洞,远程攻击者可以利用这个漏洞读取系统文件内容及进行目录遍历攻击。 问题一是addslashes()存在问题,addslashes()用于过滤用户输入,在magic_quotes_gpc设置"on"时,将对每个输入执行addslashes()进行过滤,但是由于NULL字节不正确被addslashes()编码,如果用户输入被include()或require()使用,可能导致攻击者读取文件系统的任意文件。 问题二是上传路径遍历问题,PHP自动过滤上传的文件名数据,删除在斜杠或反斜杠之前的数据,但是如果攻击者上传的文件包含单引号,而WEB服务又设置magic_quotes为ON,或者对上传文件名执行addslashes()操作,那么在单引号前会前缀一个反斜杠,因此在Windows系统可造成目录遍历问题,导致文件上传到系统任意目录中。 Warning: main(./../templates/theme_info.cfg\0/theme_info.cfg): failed to open stream: No such file or directory in f:\easyphp1-7\www\phpbb2\admin\admin_styles.php on line 78 Warning: main(): Failed opening ’./../templates/theme_info.cfg\0/theme_info.cfg’ for inclusion (include_path=’.;f:\EasyPHP1-7\php\pear\’) in f:\easyphp1-7\www\phpbb2\admin\admin_styles.php on line 7 变从了\0,phpbb就是变态,既然不行 我们在看到72行代码: 72 $install_to = ( isset($HTTP_GET_VARS[’install_to’]) ) ? urldecode($HTTP_GET_VARS[’install_to’]) : $HTTP_POST_VARS[’install_to’]; 我们使用ie提交的方式是get 那么我们提交的&install_to,要被urldecode()解析,那么我们可以先把进行url编码一次:%25%30%30 提交: http://127.0.0.1/phpBB2/a......6eb9ea1e43e62cbd634 返回: Warning: main(./../templates/theme_info.cfg): failed to open stream: No such file or directory in f:\easyphp1-7\www\phpbb2\admin\admin_styles.php on line 78 Warning: main(): Failed opening ’./../templates/theme_info.cfg’ for inclusion (include_path=’.;f:\EasyPHP1-7\php\pear\’) in f:\easyphp1-7\www\phpbb2\admin\admin_styles.php on line 7 注意和时比较      ---> main(./../templates/theme_info.cfg\0/theme_info.cfg) %25%30%30 ---> Warning: main(./../templates/theme_info.cfg) 哈哈 include成功被截断,那么我们可以利用../来调用容易文件咯 :) 具体利用 我们把phpshell代码保存为gif或其他图片格式,在通过论坛上传 然后利用构造 install_to 而被 include() 调用并执行。 这里phpshell代码代码使用 保存为 1.gif 我们到 http://127.0.0.1/phpBB2/profile.php?mode=editprofile 上传图像 返回错误:The avatar filetype must be .jpg, .gif or .png 如图1 大家都晓得图片文件都有他的“特殊标志” ,用uedit等编辑工具你就可以发现如 gif 文件的开头有“GIF89a” 看来phpbb在判断后缀后还用了 getimagesize() 或类似的函数判断,那么我们怎么绕过去呢?注意gif的文件尾部有个“0000...”的空数据区,我们就可以把php代码写到这个里面。 如图2
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部