Jump to content
  • Entries

    16114
  • Comments

    7952
  • Views

    863574398

Contributors to this blog

  • HireHackking 16114

About this blog

Hacking techniques include penetration testing, network security, reverse cracking, malware analysis, vulnerability exploitation, encryption cracking, social engineering, etc., used to identify and fix security flaws in systems.

0x00 前言本文以CVE-2023-27532為例,介紹Veeam Backup Replication漏洞調試環境的搭建方法。

0x01 簡介本文將要介紹以下內容:

環境搭建

調試環境搭建

數據庫憑據提取

CVE-2023-27532簡要分析

0x02 環境搭建1.軟件安裝安裝文檔:https://helpcenter.veeam.com/archive/backup/110/vsphere/install_vbr.html

軟件下載地址:https://www.veeam.com/download-version.html

License申請地址:https://www.veeam.com/smb-vmware-hyper-v-essentials-download.html

下載得到iso文件,安裝時需要使用郵箱獲得的License文件

2.默認目錄安裝目錄:C:\Program Files\Veeam\

日誌路徑:C:\ProgramData\Veeam\Backup

3.默認端口Veeam.Backup.Service ports: 9392,9401(SSL)

Veeam.Backup.ConfigurationService port: 9380

Veeam.Backup.CatalogDataService port: 9393

Veeam.Backup.EnterpriseService port:9394

Web UI ports: 9080,9443(SSL)

RESTful API ports: 9399,9398(SSL)

0x03 調試環境搭建1.定位進程執行命令:netstat -ano |findstr 9401

返回結果:

微信截图_20230404142903.png

定位到進程pid為7132,進程名稱為Veeam.Backup.Service.exe

使用dnSpy Attach到進程Veeam.Backup.Service.exe

2.調試設置為了在Debug過程中能夠查看變量內容,需要創建以下文件:

C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Service.ini

C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.DBManager.ini

C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.ServiceLib.ini

C:\Program Files\Veeam\Backup and Replication\Backup\Veeam.Backup.Interaction.MountService.ini

內容為:

2.png0x04 數據庫憑據提取1.獲得數據庫連接配置(1)獲得數據庫連接端口

打開SQL Server 2016 Configuration Manager,選擇SQL Server Services,可以看到SQL Server(VEEAMSQL2016)對應的Process ID為1756,如下圖

1.png查看進程對應的端口:netstat -ano|findstr 1756

返回結果:

3.png

得到連接端口49720

(2)獲得數據庫名稱

方法1:

進入Configuration Database Connection Settings,在頁面中可以看到Database name為VeeamBackup,認證方式為Windows Authentication,如下圖

下载.png

方法2:

讀取註冊表鍵值:REG QUERY 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' /v SqlDatabaseName

2.數據庫連接(1)使用界面程序

這裡使用DbSchema

選擇SqlServer,配置如下圖

3.png

成功連接如下圖

下载 (1).png

數據庫選擇VeeamBackup.dbo,進入數據庫頁面,全局搜索關鍵詞password,得到相關的查詢語句:

4.png執行後獲得數據庫存儲的憑據信息,如下圖

下载 (2).png

(2)使用Powershell

參考資料:https://github.com/sadshade/veeam-creds

veeam-creds在Veeam Backup and Replication 11及更高版本測試時會報錯,提示:

5.png

這是因為https://github.com/sadshade/veeam-creds/blob/main/Veeam-Get-Creds.ps1#L32處使用了sqloledb,當前系統的sqloledb已經過期

這裡可以選擇使用MSOLEDBSQL或MSOLEDBSQL19解決

查看當前系統是否安裝MSOLEDBSQL或MSOLEDBSQL19的Powershell命令:(New-Object System.Data.OleDb.OleDbEnumerator).GetElements() | select SOURCES_NAME, SOURCES_DESCRIPTION

返回結果示例:

6.png

以上結果顯示當前系統安裝了MSOLEDBSQL19,所以只需要將sqloledb替換為MSOLEDBSQL19即可

補充:安裝MSOLEDBSQL或MSOLEDBSQL19的方法下載地址:https://learn.microsoft.com/en-us/sql/connect/oledb/download-oledb-driver-for-sql-server?source=recommendationsview=sql-server-ver16

命令行安裝方法:msiexec /i msoledbsql.msi /qn IACCEPTMSOLEDBSQLLICENSETERMS=YES

安裝前需要滿足Microsoft Visual C++ Redistributable版本最低為14.34

查看Microsoft Visual C++ Redistributable版本的簡單方法:

通過文件夾名稱獲得:dir /o:-d 'C:\ProgramData\Package Cache'

返回結果示例:

7.png

從中可以得出Microsoft Visual C++ Redistributable版本為14.29.30037,需要安裝更高版本的Microsoft Visual C++ Redistributable,下載地址:https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

x86和x64均需要安裝,veeam-creds運行成功如下圖

下载 (3).png

0x05 CVE-2023-27532簡要分析Y4er公佈了調用CredentialsDbScopeGetAllCreds獲得明文憑據的POC:https://y4er.com/posts/cve-2023-27532-veeam-backup-replication-leaked-credentials/

1.憑據位置此處的明文憑據對應的位置為:Veeam Backup Replication Console-Manage Credentials,默認明文口令為空,如下圖

4.png調試斷點位置為Veeam.Backup.DBManager.dll-CCredentialsDbScope,如下圖

下载 (4).png

2.數據解析POC最終的返回結果為序列化之後的xml,將ParamValue作Base64解密後可以看到明文數據,但是格式不對,存在亂碼

這裡可以調用Veeam自帶的dll反序列化數據,得到正確的格式

格式化輸出字符串的代碼示例:

8.png

需要引用dll文件:

Veeam.Backup.Common.dll

Veeam.Backup.Configuration.dll

Veeam.Backup.Interaction.MountService.dll

Veeam.Backup.Logging.dll

Veeam.Backup.Model.dll

Veeam.Backup.Serialization.dll

Veeam.TimeMachine.Tool.dll

編譯生成的文件需要在本地安裝Veeam的環境下使用,否則報錯提示:

9.png 10.png

程序成功執行的結果示例如下圖

5.png0x06 小結本文以CVE-2023-27532為例,介紹搭建Veeam Backup Replication漏洞調試環境的相關問題和解決方法。