Discuz7.2的暴露网站所在路径的BUG

报错信息:
Warning: sprintf() [function.sprintf]: Too few arguments in ….\include\discuzcode.func.php on line 369

漏洞位置:
\include\discuzcode.func.php 369行附近

函数名称:
Discuz自定义的bbcodeurl函数,此函数中使用了PHP自带的函数sprintf

漏洞原因:
当用户在发帖的时候,选择使用远程图片地址,且指定了图片的宽,高,且URL中包含%百分号(比如汉字URL编码)的时候,被discuzcode.func.php程序中的discuzcode函数处理。在discuzcode函数处理图片的URL的正则替换部分,用parseimg函数进行处理,parseimg函数的三个参数全部是正则匹配的结果,三个参数依次是宽,高,URL地址。paeseimg函数又调用了bbcodeurl函数处理,并把匹配的URL当作bbcodeurl函数的第二个参数的一部分,交给bbcodeurl函数处理。的sprintf 函数的第一个参数来自用户输入的数据,程序在使用bbcodeurl函数的时候,没有检测用户输入的数据,直接把用户输入的数据作为自己参数的一部分,也就是$tags参数了。bbcodeurl函数用了sprintf函数进行字符串格式化。$tags又是第一个参数,其中,$tags字符串中的%号是格式化字符串的保留字符,以为着有几个单独的%号,就必须后接几个参数。由于程序没有判断$tags中包含几个单独的百分号,后面的参数也是固定的两个,如果URL中包含百分号的话,则导致参数的个数不对,报Warning错,就暴露了程序所在服务器的路径了(config.inc.php中的$errorreport变量限制了错误报告的对象,默认只允许报告给版主,管理人员)。

影响版本:
Discuz!7.2 (我只测试了这个版本)

现在时间:
2010-05-13 17:43

修复方法:
等待官方补丁或者转义【%】字符即可。。

临时解决办法:
discuzcode.func.php中bbcodeurl函数改成如下

function bbcodeurl($url, $tags) {
	if(!preg_match("/<.+?>/s", $url)) {
		if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {
			$url = 'http://'.$url;
		}
        $url = str_replace('%','%%',$url);
		return str_replace(array('submit', 'logging.php','%%'), array('', '','%'), sprintf($tags, $url, addslashes($url)));
	} else {
		return '&nbsp;'.$url;
	}
}

类百度知道多组头衔角色插件FOR DISCUZ7(UTF-8,GBK)

欢迎反馈意见,欢迎提交bug,欢迎批评,欢迎指教,欢迎使用并传播,请注明版权,谢谢!
去年发布了6.X系列的,基本无人问津,帖子地址http://www.discuz.net/viewthread.php?tid=1122418
看截图,文件在附件里!
screenshot1
screenshot2
screenshot3
rankgroup_for_discuz7

xoops调取Discuz最新主题,最新回复程序(block版)

使用方法:
1,下载附件,解压缩到modules目录下…
2,打开discuz/include/functions.php,修改discuz的表前缀,记得加上数据库名(例子:xoops.cdb,其中xoops为数据库名),
修改Discuz论坛的URL,网址最后不要加/,使其格式为 http://…/discuz 类似!
3,登录后台,安装模块…
4,将模块的排序设置为0,使其不在首页显示该链接…
5,到区块管理里修改其显示区块
6,删除缓存,即可

注:如发现后台区块管理中没有Discuz的两个区块,那请到群组管理中,修改权限,添加上这两个区块的权限即可!

<?php
/*
	Date:2009-5-18
	$Id: xoops_version.php   cfc4n $
*/
$modversion['name'] = _MI_DISCUZ_NAME;
$modversion['version'] = 0.1;
$modversion['description'] = _MI_DISCUZ_DESC;
$modversion['credits'] = "The Xoops Project, The Xoops China Community, Taiwen Jiang (phppp)";
$modversion['author'] = "CFC4N(cfc4nphp@gmail.com)";
$modversion['license'] = "GNU General Public License (GPL) see LICENSE";
$modversion['image'] = "images/discuz_logo.gif";
$modversion['dirname'] = "discuz";
$modversion['hasMain'] = 1;
$modversion['blocks'][0] = array(
	'file' => "discuz_block.php",
	'name' => _MI_DISCUZ_BLOCK_NEWPOST,
	'description' => "Shows new posts",
	'show_func' => "b_discuz_newpost_show",
	'options' => "",
	'template' => 'discuz_block_newpost.html');

$modversion['blocks'][1] = array(
	'file' => "discuz_block.php",
	'name' => _MI_DISCUZ_BLOCK_NEWREPLY,
	'description' => "Shows new replied topics",
	'show_func' => "b_discuz_newreply_show",
	'options' => "",
	'template' => 'discuz_block_newreply.html');
?>

xoops调取Discuz最新主题,最新回复程序(bloack版)

CNXCT小组的博客 is Stephen Fry proof thanks to caching by WP Super Cache