Persistence
WMI repository and SCCM RecentlyUsedApps
WMI repository cheat sheet: OBJECTS.DATA, event filters, consumers and bindings, WMI-Activity 5857–5861, MOF files and SCCM CCM_RecentlyUsedApps.
- Location
- C:\Windows\System32\wbem\Repository\OBJECTS.DATA
- Proves
- Fileless WMI persistence was registered; on SCCM clients, which programs ran and by whom
- Timestamps
- No creation time on subscription objects; repository $SI times (NTFS, UTC); CCM LastUsedTime as CIM DATETIME with UTC offset
- Retention
- Subscriptions persist until deleted, remnants in OBJECTS.DATA free pages; WMI-Activity log is small and rolls over quickly
- Access
- Administrator; repository files held open by the WMI service: collect via VSS or raw NTFS (KAPE WBEM); query live with Get-CimInstance
- Evidence of
- PersistenceExecution
- Type
- Database
- Windows
- XPVista / 78 / 8.11011
- KAPE target
- WBEMMOFEventLogs
- Velociraptor
- Windows.Triage.Targets:WBEMMOFEventLogs
Tools
Compare all toolsWhat it is
Windows Management Instrumentation (WMI) stores its classes and instances in the CIM repository, a set of database files under wbem\Repository. Two things in that database matter to investigators:
- Permanent event subscriptions, a well-known fileless persistence technique. An
__EventFilter(a WQL query describing a trigger), an event consumer (what to run) and a__FilterToConsumerBinding(linking the two) are stored as objects. Once bound, the WMI service runs the consumer as SYSTEM every time the filter fires, with nothing in Run keys, services or scheduled tasks. - SCCM software metering data. On Configuration Manager clients, the
CCM_RecentlyUsedAppsclass in theroot\ccm\SoftwareMeteringAgentnamespace records executables that were launched, with user, launch count and last-used time. It is a strong evidence of execution source that survives deletion of the binary.
Location
| Item | Location | Notes |
|---|---|---|
| CIM repository (Vista and later) | C:\Windows\System32\wbem\Repository\ : OBJECTS.DATA, INDEX.BTR, MAPPING1.MAP, MAPPING2.MAP, MAPPING3.MAP | All files are needed to parse objects properly |
| CIM repository (XP / 2003) | C:\Windows\System32\wbem\Repository\FS\ (plus MAPPING.VER) | |
| Event subscriptions | Namespace root\subscription (also check root\default and other namespaces) | Classes __EventFilter, __EventConsumer subclasses, __FilterToConsumerBinding |
| SCCM metering | Namespace root\ccm\SoftwareMeteringAgent, class CCM_RecentlyUsedApps | Only on ConfigMgr clients |
| WMI activity log | Microsoft-Windows-WMI-Activity/Operational (events 5857–5861) | Not available on Windows 7 / Server 2008 R2 |
| Autorecover MOFs | SOFTWARE: Microsoft\Wbem\CIMOM, value Autorecover MOFs; copies in C:\Windows\System32\wbem\AutoRecover\ | MOFs compiled with -autorecover or #pragma autorecover |
What it proves
- Persistence: a filter, a consumer and a binding with the command or script that runs, even when no file is dropped.
- Execution on SCCM clients: executable name, folder path, the last user, launch count and last-used time, plus version information of the file.
- Registration events: 5861 records a new permanent binding with its filter query and consumer details, when the log is available.
- It does not give a documented creation time for subscription objects, nor who created them. Pair it with event logs, Sysmon (events 19, 20, 21) and process creation data.
Key fields
| Object / field | Meaning |
|---|---|
__EventFilter.Name, .Query, .EventNamespace | Trigger: a WQL query such as a timer, logon or process start condition |
CommandLineEventConsumer.CommandLineTemplate / ExecutablePath | Program run by the consumer (child of WmiPrvSE.exe) |
ActiveScriptEventConsumer.ScriptText / ScriptFileName, ScriptingEngine | VBScript or JScript run by scrcons.exe |
| Other consumers | LogFileEventConsumer, NTEventLogEventConsumer, SMTPEventConsumer (rarely malicious) |
__FilterToConsumerBinding.Filter / .Consumer | References that link a filter to a consumer |
CCM_RecentlyUsedApps.ExplorerFileName, FolderPath | Executable name and folder |
LastUserName, LaunchCount, LastUsedTime | Last user, number of launches, last launch time |
FileDescription, ProductName, CompanyName, FileSize, OriginalFileName | Version-resource metadata useful for renamed tools |
Timestamps
| Timestamp | Set when | Format | Pitfalls |
|---|---|---|---|
| Subscription objects | No documented creation time | n/a | Date them with 5861, Sysmon 19–21 and the file times of the repository |
OBJECTS.DATA / INDEX.BTR $SI modified | Repository written | NTFS, UTC | Changes with normal WMI activity; only a coarse bound |
CCM_RecentlyUsedApps.LastUsedTime | Metering agent updates the record | CIM DATETIME string with UTC offset suffix | Read the offset; last launch only |
| WMI-Activity 5857–5861 | Provider loaded, error, subscription activity, new permanent binding | EVTX, UTC | Log size is small; 5861 may be the only trace of a registration |
| MOF file $SI / $FN | File dropped for compilation | NTFS, UTC | Attackers often delete the .mof after mofcomp |
Retention and clearing
- Subscriptions persist until the objects are deleted (for example with
Remove-WmiObjectorRemove-CimInstance). Deleted objects may remain in unused pages ofOBJECTS.DATAuntil overwritten; string searches of the raw file can surface them. CCM_RecentlyUsedAppskeeps records while the SCCM client is installed; older repository copies in volume shadow copies can add history.- The WMI-Activity Operational log is small and rolls over quickly on busy systems.
- When WMI rebuilds a corrupted repository, it recompiles every MOF listed in
Autorecover MOFs, so a subscription installed from an autorecover MOF comes back after the rebuild.
Collection
- KAPE target:
WBEM(the wholeRepositoryfolder),MOF(every*.MOFon the volume, which is slow) andEventLogsfor the WMI-Activity channel. - Velociraptor (
Windows.Triage.Targets):WBEM,MOF,EventLogs. Live analysis:Windows.Persistence.PermanentWMIEvents(bindings with their filters and consumers across namespaces);Windows.System.WMIQuerycan queryCCM_RecentlyUsedAppson a live client. - Built-in: the repository files are held open by the WMI service; collect them from a shadow copy or with a raw-copy tool, and query live objects with PowerShell.
Get-CimInstance -Namespace root\subscription -ClassName __EventFilter
Get-CimInstance -Namespace root\subscription -ClassName __EventConsumer
Get-CimInstance -Namespace root\subscription -ClassName __FilterToConsumerBinding
Get-CimInstance -Namespace root\ccm\SoftwareMeteringAgent -ClassName CCM_RecentlyUsedApps
wevtutil epl Microsoft-Windows-WMI-Activity/Operational E:\case\WMI-Activity.evtx
Parsing tools
- python-cim / flare-wmi (Mandiant, open source): parses an offline repository (
OBJECTS.DATA,INDEX.BTR,MAPPING*.MAP); sample scripts list persistence andCCM_RecentlyUsedAppsrecords. - WMI_Forensics (David Pany, open source):
PyWMIPersistenceFinder.pyfinds bindings by searchingOBJECTS.DATA;CCM_RUA_Finder.pyextractsCCM_RecentlyUsedAppsrecords to TSV. - Velociraptor:
Windows.Persistence.PermanentWMIEvents. - Autoruns (Sysinternals, free): WMI tab on a live system.
- EvtxECmd (Eric Zimmerman): WMI-Activity events to CSV.
- RegRipper:
wbemplugin reads theCIMOMkey, includingAutorecover MOFs.
Investigation tips
- Every binding in
root\subscriptiondeserves review; legitimate ones are few (some vendor agents) and easy to baseline across a fleet. - Look for
CommandLineEventConsumerrunningpowershell.exe,cmd.exeor LOLBins, and for anyActiveScriptEventConsumer. - Uptime or interval filters (
Win32_PerfFormattedData_PerfOS_System,__IntervalTimerInstruction) and logon or process-start filters are common triggers. - Process trees
WmiPrvSE.exe -> powershell.exeorscrcons.exeactivity point to a consumer firing; confirm with Prefetch ofSCRCONS.EXE. mofcomp.exein Prefetch or a MOF outsidewbemsuggests subscriptions were installed from a MOF file.- On SCCM clients, parse
CCM_RecentlyUsedAppseven for non-WMI cases: it often lists attacker tools that are gone from disk, Amcache and Prefetch. - Remote WMI (
wmic /node,Invoke-WmiMethod) is a lateral movement channel: correlate with network logons in the event logs.
Related artifacts
- Scheduled TasksScheduled tasks cheat sheet: task XML and .job files, TaskCache registry keys, DynamicInfo times, hidden tasks, TaskScheduler and 4698 events.
- Windows ServicesWindows services cheat sheet: Services key values (ImagePath, Start, Type, ServiceDll), 7045 and 4697 install events, PsExec traces and pitfalls.
- Run keys and Startup foldersRun keys and Startup folders cheat sheet: Run, RunOnce, Wow6432Node and Policies paths, StartupApproved enabled/disabled bytes, timestamps and pitfalls.
- Windows event logs (EVTX)Windows event log cheat sheet: EVTX locations, must-know event IDs for logons, processes, services and log clearing, retention, audit policy and parsing tools.
- Prefetch Files (.pf)Windows Prefetch cheat sheet: .pf location per version, run count, the last eight run times, referenced files, retention limits and how to parse.
- Amcache.hveAmcache.hve cheat sheet: file and program inventory keys, SHA-1 hashes, PE metadata, timestamps and why an entry alone does not prove execution.
- Sysmon Event LogSysmon cheat sheet: Operational log location, key event IDs, ProcessGuid and hash correlation, config in the registry, tampering signs and parsing tools.
Glossary terms
- PersistenceMechanisms that let malware or an attacker survive reboots and logoffs, such as Run keys, services, scheduled tasks or WMI subscriptions.
- Evidence of executionArtifacts that show a program actually ran on a Windows system, as opposed to merely existing on disk, and how strongly each one supports that claim.
- Windows event IDThe number identifying an event type within a given provider; it only has meaning when paired with its provider and log channel.
- Lateral movementAn attacker moving from one compromised host to others in the network, using RDP, SMB, PsExec, WMI, WinRM or remote tasks and services.
- LOLBin (living-off-the-land binary)A legitimate, signed Windows binary that attackers abuse to download, execute or hide payloads without dropping their own tools.