Hacking: Living of the land (WMI and Powershell Remoting)

Hacking: Living of the land (WMI and Powershell Remoting)

Hacking: Living of the land (WMI and Powershell Remoting)

Living off the land (LotL) in Windows environments uses built-in administrative tools and system frameworks instead of dropping custom malware binaries. Attackers favor Windows Management Instrumentation (WMI) and PowerShell Remoting because they are native to Windows, trusted by administrators, and frequently blend into routine IT operations.

How WMI Is Used in Living-off-the-Land Attacks

WMI is Microsoft’s implementation of WBEM It exposes hardware, operating system, and application management interfaces locally and over the network via DCOM or WinRM.

  • Reconnaissance: Querying system state, running processes, installed security software, patch levels, and domain topology using WMI classes (such as Win32_OperatingSystem, Win32_Process, or Win32_ComputerSystem).
  • Remote Execution & Lateral Movement: Invoking methods like Win32_Process.Create on remote hosts where the operator holds administrative privileges, avoiding traditional remote shell tools.
  • Persistence (WMI Event Subscriptions): Creating permanent event consumers—such as CommandLineEventConsumer or ActiveScriptEventConsumer—bound to a __EventFilter and __FilterToConsumerBinding in the root\subscription namespace so payloads trigger automatically on system events (e.g., startup or user logon).
  • Defense Evasion: Storing encoded scripts or configuration data inside WMI repository classes or custom namespaces rather than writing files to disk.

How PowerShell Remoting Is Used in Living-off-the-Land Attacks

PowerShell Remoting relies on WinRM Once enabled, it allows interactive sessions (Enter-PSSession), one-to-many command execution (Invoke-Command), and persistent background sessions (New-PSSession).

  • Lateral Movement & Pivoting: Running commands across domain-joined servers with stolen credentials or Kerberos tickets while keeping execution largely in memory on the target host.
  • Collection & Staging: Gathering Active Directory data, local files, or credentials across multiple endpoints in a single script block without copying external binaries to each machine.
  • Session & Script Abuse: Using encoded commands, proxy scripts, or constrained endpoint misconfigurations to execute administrative actions under legitimate-looking PowerShell processes (wsmprovhost.exe on the receiving host).

WMI vs. PowerShell Remoting at a Glance

DimensionWMIPowerShell Remoting (WinRM)
Core Protocol / TransportDCOM (RPC dynamic ports / TCP 135) or WinRMWS-Management over HTTP (5985) or HTTPS (5986)
Primary LotL StrengthsEvent-driven persistence, broad system queries, fileless storageRich scripting, multi-host fan-out, interactive sessions
Key Target Host ProcessWmiPrvSE.exe (WMI Provider Host)wsmprovhost.exe (WinRM host process)
Common Telemetry SourcesWMI-Activity operational logs, Sysmon Events 19–21, Process Creation (4688)PowerShell Script Block (4104), Module (4103), WinRM operational logs

Defensive Detection and Hardening

Because defenders cannot simply block WMI or PowerShell without breaking administration, effective defense focuses on visibility, least privilege, and behavioral anomalies:

  • Enable Deep Logging: Turn on PowerShell Script Block Logging (Event ID 4104) and Module Logging, alongside WMI-Activity logs and Sysmon (especially WMI event filter/consumer/binding events).
  • Restrict Administrative Boundaries: Enforce Tiering and restrict who can connect to WinRM or DCOM endpoints.
  • Harden Remoting & WMI: Disable unused WinRM listeners, enforce HTTPS with strong authentication where remote management is needed, and audit root\subscription regularly for unauthorized event consumers.
  • Hunt Behavioral Anomalies: Alert on unusual parent-child process trees (such as WmiPrvSE.exe or wsmprovhost.exe spawning shells, rundll32.exe, or credential-dumping utilities) and out-of-hours administrative connections from non-admin workstations.
Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *