FCKeditor漏洞利用

来源:互联网 发布:led改字软件 编辑:程序博客网 时间:2024/04/29 22:40
 

2006-02-09日milw0rm公布了FCKEditor的一个上传漏洞。FCKEditor是一款有多个语
言版本的(asp,cgi,aspx,php,cfm,...)的在线编辑的class,很多web系统都使用了这
个class。其实这个东西的漏洞,国内早有人挖过,比如asp版(nb文章系统由于使用这个
导致的上传漏洞),这里我们看看php版本的:
/editor/filemanager/browser/default/connectors/php/config.php

行35-36:

$Config['AllowedExtensions']['File'] = array() ; //允许的上穿类型
$Config['DeniedExtensions']['File'] = array('php','php3','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;//禁止上传的类型

我们看$Config['DeniedExtensions']['File']里禁止的类型显然不够,我们可以上传php2、php4、inc、pwml、asa、cer ...等等。我们在看看具体的upfile函数

/editor/filemanager/browser/default/connectors/php/commands.php

function FileUpload( $resourceType, $currentFolder )
{
.......................

$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ; //得到文件的后缀(以.为标志取最后1个)

global $Config ;

$arAllowed = $Config['AllowedExtensions'][$resourceType] ;
$arDenied = $Config['DeniedExtensions'][$resourceType] ;

if ( ( count($arAllowed) == 0 || in_array( $sExtension, $arAllowed ) ) && ( count($arDenied) == 0 || !in_array( $sExtension, $arDenied ) ) ) //判断合法后缀
{
$iCounter = 0 ;

while ( true )
{
$sFilePath = $sServerDir . $sFileName ;

.......................

move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
//上传 注意它保存的文件直接用的$sFilePath = $sServerDir . $sFileName,而没有使用$sExtension为后缀
//导致在win下在上传文件后面加个.来突破[未测试]
........................
}

为什么说这个漏洞为"意识漏洞"呢?如果我们把AllowedExtensions/DeniedExtensions的设置"反"一下:

$Config['AllowedExtensions']['File'] = array('rar','zip') ; //允许的上穿类型
$Config['DeniedExtensions']['File'] = array() ;//禁止上传的类型

把设置DeniedExtensions改为设置AllowedExtensions,就不会出现上面的漏洞了,不过这样在某些情况下,照样可以突破,问题还是出在这里:

move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
//上传 注意它保存的文件直接用的$sFilePath = $sServerDir . $sFileName,而没有使用$sExtension为后缀

在apache下,因为"apache文件名解析缺陷漏洞"而出现漏洞[未测试]。

小结:
其实很多web程序员都有这个"意识漏洞",在过滤上传文件类型时,不应该‘被动’的去过滤非法后缀,应该是‘主动’过滤允许上传的类型。

原创粉丝点击