登录社区:用户名: 密码: 忘记密码 网页功能:加入收藏 设为首页 网站搜索  

文档

下载

图书

论坛

安全

源码

硬件

游戏
首页 信息 空间 VB VC Delphi Java Flash 补丁 控件 安全 黑客 电子书 笔记本 手机 MP3 杀毒 QQ群 产品库 分类信息 编程网站
  立华软件园 - 安全技术中心 - 技术文档 - 漏洞分析 技术文章 | 相关下载 | 电子图书 | 攻防录像 | 安全网站 | 在线论坛 | QQ群组 | 搜索   
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
 其他安全技术资源
  · 攻防演示动画
  · 电子图书
  · QQ群组讨论区
  · 其他网站资源
最新招聘信息

WordPress wp-trackback.php漏洞分析
发表日期:2007-03-13作者:HeiGe[转贴] 出处:安全焦点  

WordPress wp-trackback.php漏洞分析
      文/Superhei 2007/1/9
1.Stefan Esser大牛2007/01/05发布的WordPress Trackback Charset Decoding SQL Injection Vulnerability [1]

Code:wp-trackback.php

$tb_url    = $_POST['url'];
$title     = $_POST['title'];
$excerpt   = $_POST['excerpt'];
$blog_name = $_POST['blog_name'];
$charset   = $_POST['charset'];
.......
if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
    $title     = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
    $excerpt   = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
    $blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset);
}
.......
$dupe = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_author_url = '$comment_author_url'");

变量$charset编码post--->mb_convert_encoding()转换为get_settings('blog_charset') [utf-8]---->select

se大牛的exp[2] 是用的uf7编码:'==>+-ACc- 饶过gpc,然后通过mb_convert_encoding转化为utf-8 '<==+-ACc-

其实这个就是编码引起的2次攻击[3]饶过gpc引起的SqlInj。

官方发布的补丁:2.0.6 wp-trackback.php

// These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
$title     = stripslashes($_POST['title']);
$excerpt   = stripslashes($_POST['excerpt']);
$blog_name = stripslashes($_POST['blog_name']);
.........
// Now that mb_convert_encoding() has been given a swing, we need to escape these three
$title     = $wpdb->escape($title);
$excerpt   = $wpdb->escape($excerpt);
$blog_name = $wpdb->escape($blog_name);

变量经过stripslashes()--->mb_convert_encoding()--->escape()--->select

我们看看escape() :wp-includes\wp-db.php

    function escape($string) {
        return addslashes( $string ); // Disable rest for now, causing problems
        if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' )
            return mysql_escape_string( $string );
        else
            return mysql_real_escape_string( $string, $this->dbh );
    }

mysql_real_escape_string()在一定的条件下是可以绕过的:
The addslashes() Versus mysql_real_escape_string() Debate  http://shiflett.org/archive/184
村雨牛牛在xcon也说过,但是mysql支持gbk的情况还是比较少的。有兴趣的可以自己测试下 :)

2.rgod于2007/01/08发布的WordPress <= 2.0.6 wp-trackback.php Zend_Hash_Del_Key_Or_Index / sql injection exploit [4]

Code:wp-settings.php

function unregister_GLOBALS() {
    if ( !ini_get('register_globals') )
        return;

    if ( isset($_REQUEST['GLOBALS']) )
        die('GLOBALS overwrite attempt detected');

    // Variables that shouldn't be unset
    $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
   
    $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
    foreach ( $input as $k => $v )
        if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
            unset($GLOBALS[$k]);
}

unregister_GLOBALS();

这里unset了$_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, $_SESSION 等提交的变量。

Code:wp-trackback.php

if ( !intval( $tb_id ) ) //注意这个
    trackback_response(1, 'I really need an ID for this to work.');

.................

if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
    header('Content-Type: text/xml; charset=' . get_option('blog_charset') );

    $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
......

$tb_id没有’ 通过unset后存在end_Hash_Del_Key_Or_Index漏洞,导致注射。在分析时候提交:tb_id='&1740009377=1&496546471=1
返回:I really need an ID for this to work 原来是在 :
if ( !intval( $tb_id ) ) //这里拦住了。
    trackback_response(1, 'I really need an ID for this to work.');
   
提交tb_id=1'&1740009377=1&496546471=1 成功触发,这里引发了一比较有意思的问题 :
<?
//test.php
print intval($_REQUEST["id"]);
?>
提交test.php?id=a1 得到 0,提交test.php?id=12a 得到 12。
可以看出 intval是根据第1个字符来判断的,这样如果是像wp这样的判断:if ( !intval( $_ ) ) 还是有安全隐患的。

 

我来说两句】 【发送给朋友】 【加入收藏】 【返加顶部】 【打印本页】 【关闭窗口
中搜索 WordPress wp-trackback.php漏洞分析

 ■ [欢迎对本文发表评论]
用  户:  匿名发出:
您要为您所发的言论的后果负责,故请各位遵纪守法并注意语言文明。

最新招聘信息

关于我们 / 合作推广 / 给我留言 / 版权举报 / 意见建议 / 广告投放 / 友情链接  
Copyright ©2001-2006 Lihuasoft.net webmaster(at)lihuasoft.net
网站编程QQ群   京ICP备05001064号 页面生成时间:0.00197