menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right ... chevron_right 033-DedeCMS chevron_right 008-CVE-2019-8362 Dedecms v5.7 sp2 后台文件上传 getshell.md
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    008-CVE-2019-8362 Dedecms v5.7 sp2 后台文件上传 getshell.md
    1.56 KB / 2021-07-17 00:01:28
        # CVE-2019-8362 Dedecms v5.7 sp2 后台文件上传 getshell
    
    ## 一、漏洞简介
    
    上传zip文件解压缩对于文件名过滤不周,导致getshell
    
    ## 二、漏洞影响
    
    ## 三、复现过程
    
    代码分析
    
    `/dede/album_add.php` 175行验证后缀
    
    `$fm->GetMatchFiles($tmpzipdir,"jpg|png|gif",$imgs);`
    
    进入函数:
    
    
    ```php
    function GetMatchFiles($indir, $fileexp, &$filearr)
       {
           $dh = dir($indir);
           while($filename = $dh->read())
           {
               $truefile = $indir.'/'.$filename;
               if($filename == "." || $filename == "..")
               {
                   continue;
               }
               else if(is_dir($truefile))
               {
                   $this->GetMatchFiles($truefile, $fileexp, $filearr);
               }
               else if(preg_match("/\.(".$fileexp.")/i",$filename))
               {
                   $filearr[] = $truefile;
               }
           }
           $dh->close();
       }
    ```
    
    可以确定`preg_match("/.(".$fileexp.")/i",$filename)`只是判断了文件名中是否存在`.jpg、.png、.gif`中的一个,只要构造`1.jpg.php`就可以绕过。
    
    **复现**
    
    1、首先构造一个文件名为`1.jpg.php`的文件,内容为
    
    2、将该文件进行压缩
    
    3、在常用操作-文件式管理器处上传压缩文件到soft目录下
    
    ![](images/15889903875298.png)
    
    
    ![](images/15889903916371.png)
    
    
    4、访问`dede/album_add.php`,选择从 从ZIP压缩包中解压图片
    
    ![](images/15889904026146.png)
    
    
    5、发布预览
    
    ![](images/15889904107561.png)
    
    
    ![](images/15889904145049.png)
    
    
    ![](images/15889904189952.png)
    
    
    ![](images/15889904275158.gif)
    
    
    links
    file_download