首页 安全基础 网络安全 安全协议 病毒分析 防火墙 OS安全 无线安全 Web安全 PKI与PMI 入侵检测 经典案例
安全审计 设备安全 安全管理 安全标准 法律法规 隔离网闸 DB安全 XML安全 开源项目 资源下载 安全论坛 备份恢复
 当前位置:首页>>DB安全>>综合文章>>正文
xoops存在sql注入缺陷
文章出处:不详   发布时间:2005-06-12   点击:0
 

  涉及程序:
xoops 1.3.x版,2.0.x版到2.0.5版
  
描述:
xoops存在sql注入缺陷
  
详细:
xoops是一款用php编写的动态web站点程序。

xoops程序banners.php文件中的代码存在错误,允许未经授权的用户重定义本地变量并注入sql命令:


  code: [copy to clipboard]   
<?

[...]

function emailstats($login, $cid, $bid, $pass)
{
global $xoopsdb, $xoopsconfig;
$result2 = $xoopsdb->query("select name, email from
".$xoopsdb->prefix("bannerclient")." where cid=$cid");
list($name, $email) = $xoopsdb->fetchrow($result2);
if ( $email == "" ) {
redirect_header("banners.php",3,"there isn't an email associated with
client ".$name.".<br />please contact the administrator");

exit();
} else {
$result = $xoopsdb->query("select bid, imptotal, impmade, clicks,
imageurl, clickurl, date from ".$xoopsdb->prefix("banner")." where bid=$bid
and cid=$cid");
list($bid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date) =
$xoopsdb->fetchrow($result);
[...]

$fecha = date("f js y, h:ia.");
$subject = "your banner statistics at ".$xoopsconfig[sitename]."";
$message = "following are the complete stats for your advertising
investment at ". $xoopsconfig['sitename']." :\n\n\nclient name:
$name\nbanner id: $bid\nbanner image: $imageurl\nbanner url:
$clickurl\n\nimpressions purchased: $imptotal\nimpressions made:
$impmade\nimpressions left: $left\nclicks received: $clicks\nclicks percent:
$percent%\n\n\nreport generated on: $fecha";
$xoopsmailer =& getmailer();
$xoopsmailer->usemail();
$xoopsmailer->settoemails($email);
$xoopsmailer->setfromemail($xoopsconfig['adminmail']);
$xoopsmailer->setfromname($xoopsconfig['sitename']);
$xoopsmailer->setsubject($subject);
$xoopsmailer->setbody($message);
$xoopsmailer->send();
redirect_header("banners.php?op=ok&login=$login&pass=$pass",3,"stati
stics
for your banner has been sent to your email address.");
//include "footer.php";
exit();
}
}

function change_banner_url_by_client($login, $pass, $cid, $bid, $url)
{
global $xoopsdb;
$result = $xoopsdb->query("select passwd from
".$xoopsdb->prefix("bannerclient")." where cid=".$cid."");
list($passwd) = $xoopsdb->fetchrow($result);
if ( $pass == $passwd ) {
$xoopsdb->queryf("update ".$xoopsdb->prefix("banner")." set
clickurl='".$url."' where bid=".$bid."");
}
redirect_header("banners.php?op=ok&login=$login&pass=$pass",3,"url
has been changed.");
//include "footer.php";
exit();
}

[...]

switch ( $op ) {
case "change":
change_banner_url_by_client($login, $pass, $cid, $bid, $url);
break;
case "emailstats":
emailstats($login, $cid, $bid, $pass);
break;
[...]
}

?>  



攻击者通通过向目标服务器提交精心构造的下列格式的url请求能触发该缺陷:
http://[target]/banners.php?op=emailstats&cid=1%20and%20passwd%20like%20'a%'/*  
  
攻击方法:
示例代码:
http://[target]/banners.php?op=emailstats&cid=1%20and%20passwd%20like%20'a%'/*  
  
解决方案:
用下列代码替换banners.php文件中的change_banner_url_by_client()函数:


  code: [copy to clipboard]   
function change_banner_url_by_client($login, $pass, $cid, $bid, $url)
{
global $xoopsdb;
if ( !empty($cid) and !empty($bid) and !empty($pass) ){
$result = $xoopsdb->query("select passwd from
".$xoopsdb->prefix("bannerclient")." where cid='".$cid."'");
list($passwd) = $xoopsdb->fetchrow($result);
if ( $pass == $passwd ) {
$xoopsdb->queryf("update ".$xoopsdb->prefix("banner")." set
clickurl='".$url."' where bid='".$bid."'");
}
redirect_header("banners.php?op=ok&login=$login&pass=$pass",3,"url
has been changed.");
//include "footer.php";
}
exit();
}  



在“switch($op) {”前添加下列代码:
$cid = intval($cid);
$bid = intval($bid);


 

作者:
[返回顶部↑]  [推荐好友] [查看评论]  
用户名: 新注册) 密码: 匿名评论 [查看评论]  发表评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 
↑文章搜索
  关键字:  
  范  围:  
  开始搜索  
※相关文章※
 

◎如何在mssql中执行系统命令
◎sql的sa空口令漏洞怎么补
◎sql数据库的一些攻击
◎linux系统各文件、目录介绍
◎如何修改internal的口令
◎microsoft sqlserver安装示
◎如何安装 sql server 2000

 
※热点文章※
  ·SQL数据库的一些攻击
·保护数据库服务器加强数据
·从IIS转到SQL数据库安全
·SQL完全简明手册
·IBMWCS访问数据库密码明文
·sql数据库的一些攻击
·怎样使mysql安全以对抗解密
 

关于我们 | 征搞启示 | 版权信息 | 联系我们 | 友情链接

版权所有:中国信息安全组织 © 2003-2005 Power by DedeCms