当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2014-072109

漏洞标题:ThinkSAAS 2.2 GET型CSRF到Getshell

相关厂商:thinksaas.cn

漏洞作者: phith0n

提交时间:2014-08-12 20:21

修复时间:2014-11-10 20:22

公开时间:2014-11-10 20:22

漏洞类型:CSRF

危害等级:中

自评Rank:10

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-08-12: 细节已通知厂商并且等待厂商处理中
2014-08-12: 厂商已经确认,细节仅向厂商公开
2014-08-15: 细节向第三方安全合作伙伴开放
2014-10-06: 细节向核心白帽子及相关领域专家公开
2014-10-16: 细节向普通白帽子公开
2014-10-26: 细节向实习白帽子公开
2014-11-10: 细节向公众公开

简要描述:

后台Getshell本想在XSS漏洞里一起提交的。。。结果我给忘了。
不过后来发现这个洞是Get型的CSRF,利用方便,老少咸宜,在社区CMS中可以说威力无限呀。

详细说明:

/app/system/action/plugin.php 83行:

case "delete":
$apps = $_GET['apps'];
$pname = $_GET['pname'];

delDir('plugins/'.$apps.'/'.$pname);

qiMsg('删除成功!');
break;


获得了GET到的值以后拼接成路径以后传入delDir函数。delDir函数:

/**
* 删除文件夹和文件夹下所有的文件
* @param string $dir
* @return boolean
*/
function delDir($dir = '') {
if (empty ( $dir )) {
$dir = rtrim ( RUNTIME_PATH, '/' );
}
if (substr ( $dir, - 1 ) == '/') {
$dir = rtrim ( $dir, '/' );
}
if (! file_exists ( $dir ))
return true;
if (! is_dir ( $dir ) || is_link ( $dir ))
return @unlink ( $dir );
foreach ( scandir ( $dir ) as $item ) {
if ($item == '.' || $item == '..')
continue;
if (! delDir ( $dir . "/" . $item )) {
@chmod ( $dir . "/" . $item, 0777 );
if (! delDir ( $dir . "/" . $item ))
return false;
}
;
}
return @rmdir ( $dir );
}


就是一个删除的函数。所以,这个CSRF可以直接通过GET方式删除任意文件。
通过插入这个链接即可删除config.inc.php:

http://localhost/think/index.php?app=system&ac=plugin&ts=delete&apps=1&pname=../../data/config.inc.php


至于怎么getshell,比较简单。删除了config.inc.php以后就可以重装系统了。
1.重装时候插配置文件可以getshell。
2.提供一个新方式:
/thinksaas/thinksaas.php中有这么一句:

//安装专用变量
$install = isset($_GET['install']) ? $_GET['install'] : 'index';
//安装配置文件,数据库配置判断
if(!is_file('data/config.inc.php')){
include 'install/index.php';
exit;
}


如果配置文件不存在则包含install/index.php
看看:

<?php
defined('IN_TS') or die('Access Denied.');
/*
*ThinkSAAS 安装程序
* @copyright (c) 2010-3000 ThinkSAAS All Rights Reserved
* @code by QiuJun
* @Email:[email protected]
*/
//安装文件的IMG,CSS文件
$skins = 'data/install/skins/';
//进入正题
$title = 'ThinkSAAS安装程序';
require_once 'action/'.$install.'.php';


$install是刚才$_GET到的变量(这个时候GET还没有经过addslashes过滤),直接截断包含,也能够getshell。

漏洞证明:

登录后台后直接访问http://localhost/think/index.php?app=system&ac=plugin&ts=delete&apps=1&pname=../../data/config.inc.php即可删除重装。

修复方案:

后台也要过滤。而且似乎csrf token好像没起到作用呀?

版权声明:转载请注明来源 phith0n@乌云


漏洞回应

厂商回应:

危害等级:中

漏洞Rank:8

确认时间:2014-08-12 23:03

厂商回复:

感谢反馈,官网社区已经修复,稍后会在版本发布中更新

最新状态:

暂无