|  | FCKEditor是一个用的非常广泛的html文本编辑器,许多程序和大型网站里都集成了这个免费的编辑器。 
 以前幻影的superhei曾经发过一个文件上传漏洞,但是这个漏洞补了好几次,却一直没不干净。
 
 详情请见全文。
 文/superhei
 以前发过一个fckeditor的上传文件漏洞:http://superhei.blogbus.com/logs/2006/02/1916091.html
 我们看看新版本2.4的,还是被动过滤:
 
 
 config.php:
$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') ;
 字典越来越大啊 :) 。我们先测试先以前的exp
 上穿aa.php. 这样的文件结果变成了 aa_php. 看来还有其他变化啊:
 
 
 function FileUpload( $resourceType, $currentFolder )
{
    $sErrorNumber = '0' ;
    $sFileName = '' ;
            ..........
        // Replace dots in the name with underscores (only one dot can be there... security issue).
        if ( $Config['ForceSingleExtension'] ) //多了个$Config['ForceSingleExtension']的配置 默认是ture
            $sFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sFileName ) ; //这里替换了文件名里多余的. 即:1.1.php-->1_1.php
        $sOriginalFileName = $sFileName ;
        // Get the extension.
        $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
        $sExtension = strtolower( $sExtension ) ; //替换后取后缀,因为上面的替换所以保证了文件名里只有一个.  即:1_1.php--->php
        $arAllowed    = $Config['AllowedExtensions'][$resourceType] ;
        $arDenied    = $Config['DeniedExtensions'][$resourceType] ;
        if ( ( count($arAllowed) == 0 || in_array( $sExtension, $arAllowed ) ) && ( count($arDenied) == 0 || !in_array( $sExtension, $arDenied ) ) )//判断
        {
          .............
                if ( is_file( $sFilePath ) )
                {
                    $iCounter++ ;
                    $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
/*
这里判断有没有相同的文件名,如果有这改为在后缀前加一个(n). 如:_phs-->(1)._phs
那么我们可以利用产生的这个(n).不呢?答案是:NO 因为我们提交_php 经过     
// Get the extension.
$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;
这里时strrpos($sFileName, '.')为空所以 还是:_php-->php 这个是没有办法通过上面的判断语句的
*/
                    $sErrorNumber = '201' ;
                }
                else
                {
                    move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
 
 通过上面的分析,好象没办法了?。呵呵 我们可以不用.嘛,在win下还有一个空格呢 :) 提交1.php+空格 就可以过去所有的拉 hoho
 不过空格只支持win系统 *nix是不支持的[1.php和1.php+空格是2个不同的文件]
 
 最后说明下,默认fckeditor是不让上传文件的:
 
 
 config.php:
// SECURITY: You must explicitelly enable this "connector". (Set it to "true").
$Config['Enabled'] = false  ;
 
 最后bs下fckeditor,为了被动的过滤,费了多少事啊 最后还是有问题!意识问题!!!??
 
 |