freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

五指cms任意文件删除漏洞分析
2020-11-10 20:23:26

前言

五指cms由国内专业的网站内容管理系统提供商北京五指互联科技有限公司开发,是一款开源的内容管理系统,使用php5+mysql开发,但是在2017年就停止了维护,之前也披露过不少漏洞,接下来就开启挖洞之旅。

过程

跟进了几个文件后我们来到了coreframe/app/attachment/admin/index.php:
/**
* 目录列表方式查看
*
* @author tuzwu
* @createtime 2014-8-1 13:14:29
* @modifytime
* @param
* @return array
*/
public function dir()
{
$dir = isset($GLOBALS['dir']) && trim($GLOBALS['dir']) ? str_replace(array('..\\', '../', './', '.\\'), '', trim($GLOBALS['dir'])) : '';
$dir = str_ireplace(array('%2F', '//'), '/', $dir);
$lists = glob(ATTACHMENT_ROOT . $dir . '/' . '*');
if (!empty($lists)) rsort($lists);
$cur_dir = str_replace(array(WWW_ROOT, DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR), array('', DIRECTORY_SEPARATOR), ATTACHMENT_ROOT . $dir . '/');
include $this->template('dir', M);
}
在调用str_replace()函数对dir参数的输入进行过滤时,会将'..\\', '../', './', '.\\'直接过滤掉,我们这里直接输入"..",目录直接遍历:
光遍历没什么危害啊,也不能下载或者访问,但是WUZHI CMS后台为了方便自带删除的功能,但是只能删除这一级目录的文件吗?带着疑问继续跟进,我们再看coreframe/app/attachment/admin/index.php的另一处:
/**
* 删除文件
*
* @author tuzwu
* @createtime
* @modifytime
* @param
* @return
*/
public function del()
{
$id = isset($GLOBALS['id']) ? $GLOBALS['id'] : '';
$url = isset($GLOBALS['url']) ? remove_xss($GLOBALS['url']) : '';
if (!$id && !$url) MSG(L('operation_failure'), HTTP_REFERER, 3000);
if ($id) {
if(!is_array($id)) {
$ids = array($id);
} else {
$ids = $id;
}
foreach($ids as $id) {
$where = array('id' => $id);
$att_info = $this->db->get_one('attachment', $where, 'usertimes,path');
if ($att_info['usertimes'] > 1) {
$this->db->update('attachment', 'usertimes = usertimes-1', $where);
}
else {
$this->my_unlink(ATTACHMENT_ROOT . $att_info['path']);
$this->db->delete('attachment', $where);
$this->db->delete('attachment_tag_index', array('att_id'=>$id));
}
}
MSG(L('delete success'), HTTP_REFERER, 1000);
}
else {
if (!$url) MSG('url del ' . L('operation_failure'), HTTP_REFERER, 3000);
$path = str_ireplace(ATTACHMENT_URL, '', $url);
if ($path) {
$where = array('path' => $path);
$att_info = $this->db->get_one('attachment', $where, 'usertimes,id');
if (empty($att_info)) {
$this->my_unlink(ATTACHMENT_ROOT . $path);
MSG(L('operation_success'), HTTP_REFERER, 3000);
}
if ($att_info['usertimes'] > 1) {
$this->db->update('attachment', 'usertimes = usertimes-1', array('id' => $att_info['id']));
}
else {
$this->my_unlink(ATTACHMENT_ROOT . $path);
$this->db->delete('attachment', array('id' => $att_info['id']));
MSG(L('operation_success'), HTTP_REFERER, 3000);
}
}
else {
MSG(L('operation_failure'), HTTP_REFERER, 3000);
}
}
}
对url参数的输入貌似没有做任何控制,首先我们先删除robots.txt
然后我们在url参数这里发现果然没有限制,可以任意文件删除。
# 挖洞经验
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录