天天看點

FCKeditor漏洞總結

雖然是老話題了,但是還是有很多大網站在此栽了跟頭,在這裡不是讓大家去搞破壞,幹壞事,而是提醒大家提高防範意識,保護資訊安全……

FCKeditor介紹

FCKeditor是一款功能強大的開源線上文本編輯器(DHTML editor),它使你在web上可以使用類似微軟Word 的桌面文本編輯器的許多強大功能。它是輕量級且不必在用戶端進行任何方式的安裝。 FCKeditor相容Firefox, Mozilla, Netscape 和IE。

FCKeditor官司方網址:http://www.fckeditor.net/

FCKeditor線上DEMO:http://www.fckeditor.net/demo

FCKeditor下載下傳直址:http://www.fckeditor.net/download

确認程式為FCKeditor

要對漏洞進行測試,首先我們要确認網站中使用的編輯功能是不是由FCKeditor進行支援的。确認的方法很簡單,打開網站帶有編輯功能的頁面,通常是發表文章或文章的頁面。單擊IE菜單欄上的“檢視”按鈕,選擇“源檔案”,以“FCKeditor”為關鍵 字進行搜尋,如果能搜尋到,那麼基本上可以确認該編輯功能使用的是FCKeditor。例如著名的部落格程式Pjblog就可以通過這種方法得知其使用的就是FCKeditor。不過确認是FCKeditor并不代表其就有漏洞,因為這個漏洞隻存在于之前的版本中,但是目前存在漏洞的 FCKeditor還是比較多的。

Google搜尋:inurl:Fckeditor/editor

上傳asp木馬

确定網站中使用的是FCKeditor後,可以直接在IE位址欄中輸入:http://www.***.com/FCKeditor /_samples/default.html。預設情況下可以打開一個FCKeditor編輯頁面,有些精簡版的FCKeditor會将 _samples檔案夾删除,是以可能出現“找不到網頁”的情況。在出現的頁面中點選“插入/編輯圖像”圖示,打開“圖像屬性”視窗,點選其中的“浏覽服 務器”伺服器按鈕,将出現一個檔案上傳頁面。我們在這個頁面上單擊滑鼠右鍵,選擇“屬性”,在“位址”一項中将找到這個頁面的真實位址:

http://www.***.com/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/asp/connector.asp。

将 找到的位址複制到IE位址欄中打開,出現一個上傳檔案管理頁面,此時我們就可以上傳我們的asp木馬了,不過在上傳之前我們需要将asp木馬的字尾名改為 asa,因為FCKeditor限制了asp檔案的上傳,卻沒有限制asa檔案的上傳,而asp檔案和asa檔案的執行效果是一樣的,這就是 FCKeditor的漏洞所在——上傳檔案的過濾不嚴。

上傳asp木馬完成後,就可以在浏覽器中執行木馬,此時我們得到的是一個webshell,可以對網站中任意檔案進行操作,如果想黑掉網站,也是輕而易舉的事。可見,雖然FCKeditor功能做得很強大,在安全性方面卻很薄弱。

如果通過上面的步驟進行測試沒有成功,可能有以下幾方面的原因:

1.FCKeditor沒有開啟檔案上傳功能,這項功能在安裝FCKeditor時預設是關閉的。如果想上傳檔案,FCKeditor會給出錯誤提示。

2.網站采用了精簡版的FCKeditor,精簡版的FCKeditor很多功能丢失,包括檔案上傳功能。

3.FCKeditor的這個漏洞已經被修複。

FCKeditor上傳路徑

比如輸入:

http://[target]/[path]/FCKeditor/editor/filemanager/browser/default/browser.html?Type=all&Connector=connectors/asp/connector.asp

上傳檔案位址是UserFiles/all/1.asa

“Type=all” 這個變量是自己定義的,在這裡建立了all這個目錄,而且新的目錄沒有上傳檔案格式的限制.

type=xxx

所傳的檔案就到了http://[target]/[path]/UserFiles/xxx/下了

type=../

所傳檔案就到網站根目錄了.

FCKeditor的JSP版漏洞

檢視配置和列出目錄下的檔案:

http://www.xxx.com/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector?Command=FileUpload&Type=Image&CurrentFolder=%2F

上傳shell的位址:

http://www.xxx.com/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector

跟版本有關系.并不是百分百成功.

FCKeditor的PHP版漏洞

1. 上傳檔案漏洞,适用版本2.4.2以下:

fckeditor/editor/filemanager/upload/php/upload.php 61行未對Media類型進行上傳檔案類型的控制,導緻使用者上傳任意檔案。修補辦法:更新到最新的2.5版本。或者在config.php檔案中,添加對Media類型的檔案類型限制。

2. 被動過濾:

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 經過

$sExtension = strtolower( $sExtension ) ;

這裡時strrpos($sFileName, ‘.’)為空是以 還是:_php–>php 這個是沒有辦法通過上面的判斷語句的

*/

$sErrorNumber = ’201′ ;

}

else

move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;

通過上面的分析,好象沒辦法了?。呵呵 我們可以不用.嘛,在win下還有一個空格呢 / 送出1.php+空格 就可以過去所有的。不過空格隻支援win系統 *nix是不支援的[1.php和1.php+空格是2個不同的檔案]

最後說明下,預設fckeditor是不讓上傳檔案的:config.php:

// SECURITY: You must explicitelly enable this “connector”. (Set it to “true”).

$Config['Enabled'] = false ;

漏洞的修複

FCKeditor的漏洞因上傳功能而起,是以隻要我們将上傳功能徹底關閉就可以了。打開位于FCKeditor安裝目錄 editor/filemanager/browser/default/connectors/asp/檔案夾中的config.asp檔案,将其中的 ConfigIsEnabled參數後面的值改為False,這樣做的目的是将FCKeditor的檔案上傳功能關閉,漏洞當然也就無法被黑客利用了。

其實最簡單的方法就是更新FCKeditor的版本,更新後漏洞就不存在了。如果FCKeditor是嵌入在網站程式中的,那麼可能更新後會比較麻煩,這時采用第一種方法即可。

繼續閱讀