Remote Code Execution Methods
What you'll learn: How attackers leverage built-in Windows administration tools—PsExec, WMI, DCOM, and WinRM—to execute commands on remote systems during lateral movement.
Understanding Remote Code Execution in Enterprise Environments
Once you've compromised credentials through Pass-the-Hash or Pass-the-Ticket attacks, the next step is executing code on target systems. Instead of exploiting vulnerabilities, attackers often abuse legitimate administrative tools that Windows provides for remote management.
Think of these tools as master keys that system administrators use daily—but in an attacker's hands, they become pathways for lateral movement across the network.
Four Primary Remote Execution Methods
PsExec
A Sysinternals tool that copies an executable to the target's ADMIN$ share and creates a remote service to run it. Requires administrative credentials and SMB access (port 445). It's noisy but effective, leaving service creation events in logs.
Windows Management Instrumentation (WMI)
A powerful management framework that can execute commands remotely via the Win32_Process class. Uses DCOM (port 135) or WinRM protocols. Stealthier than PsExec since it doesn't write files to disk before execution.
Distributed Component Object Model (DCOM)
Enables communication between software components across networked machines. Attackers abuse specific DCOM objects like MMC20.Application or ShellWindows to execute arbitrary commands remotely with minimal logging.
Windows Remote Management (WinRM)
Microsoft's implementation of WS-Management protocol (ports 5985/5986). PowerShell remoting uses WinRM, allowing scriptblock execution on remote systems. Increasingly common in modern environments and considered "living off the land."
Detection and Defense
Each method leaves different forensic artifacts: PsExec creates services, WMI generates event IDs 4688 and 7045, DCOM activity appears in Sysmon, and WinRM logs remote sessions. Defenders monitor these signatures to detect lateral movement.
Key Takeaway: Remote code execution for lateral movement exploits legitimate administrative tools like PsExec, WMI, DCOM, and WinRM—each with unique stealth characteristics and detection signatures that both attackers and defenders must understand.