Artifact Analysis: PsExec and Lateral Movement
1. The Anatomy of Remote Execution
Section titled “1. The Anatomy of Remote Execution”To effectively hunt for PsExec, DFIR analysts must understand its highly specific execution flow. The tool does not rely on traditional exploits; instead, it abuses legitimate Windows administrative shares and the Service Control Manager (SCM).
- Authentication: The attacker executes
psexec.exefrom the source machine, providing credentials that hold local administrator privileges on the target endpoint. - SMB & Hidden Share Access: PsExec authenticates over port 445 and mounts the target’s administrative hidden share, typically
ADMIN$(which maps toC:\Windows). - Payload Dropping: The tool copies a specific service executable, named
PSEXESVC.exe, into the target’s%SystemRoot%directory. - Service Creation: Using Remote Procedure Calls (RPC), PsExec interacts with the target’s Service Control Manager to create a temporary, demand-start Windows service named
PSEXESVC. - Execution & Named Pipes: The SCM starts the service, which executes with
NT AUTHORITY\SYSTEMprivileges. The service then creates a named pipe (e.g.,\pipe\psexecsvc) to redirect standard input/output (stdin/stdout) back to the attacker’s terminal, establishing an interactive shell. - Cleanup (Anti-Forensics): Upon session termination, PsExec attempts to stop the service, delete the service configuration, and remove the
PSEXESVC.exebinary.
2. Forensic Investigation & Traces
Section titled “2. Forensic Investigation & Traces”While PsExec attempts to clean up after itself, the execution chain generates highly durable artifacts across the Windows event logs and the file system.
A. Windows Event Logs (The Primary Source)
Section titled “A. Windows Event Logs (The Primary Source)”- Event ID 7045 (Service Creation): This is the highest-fidelity indicator. Look in the
Systemlog for a new service installed with the namePSEXESVCand the image pathC:\Windows\PSEXESVC.exe. Even if the attacker successfully deletes the service later, the creation event remains permanently logged. - Event ID 4624 (Successful Logon): In the
Securitylog, you will observe a sequence:- A Logon Type 3 (Network) representing the SMB authentication to the
ADMIN$share. - Followed immediately by a Logon Type 5 (Service) when the
SYSTEMaccount starts the dropped service.
- A Logon Type 3 (Network) representing the SMB authentication to the
- Event ID 4688 (Process Creation): If command-line auditing is enabled, analysts will observe a highly distinctive process lineage:
services.exe->PSEXESVC.exe->cmd.exe(or the specific payload executed by the attacker).
B. File System & Execution Artifacts
Section titled “B. File System & Execution Artifacts”If the attacker’s connection drops unexpectedly or the cleanup routine fails, the PSEXESVC.exe binary will be left orphaned in the C:\Windows\ directory.
Even if successfully deleted, analysts should cross-reference Prefetch (.pf) Files and Amcache on the target machine. These artifacts will definitively prove that PSEXESVC.exe was executed, providing precise execution timestamps.
3. The “Impacket” Variant Nuance
Section titled “3. The “Impacket” Variant Nuance”In modern incident response, threat actors (including ransomware groups like Akira and Qilin) rarely use the official Microsoft binary. Instead, they use psexec.py from the Impacket library.
4. Detection & Threat Hunting
Section titled “4. Detection & Threat Hunting”Deploy the following Sigma rule to detect the specific process lineage associated with PsExec and its variants.
title: Suspicious PsExec Service Executionid: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6dstatus: stabledescription: Detects the execution of cmd.exe or powershell.exe as a child of PSEXESVC.exe, indicating lateral movement.logsource: category: process_creation product: windowsdetection: selection: ParentImage|endswith: '\PSEXESVC.exe' Image|endswith: - '\cmd.exe' - '\powershell.exe' condition: selectionlevel: hightags: - attack.lateral_movement - attack.t1569.002# Detects the creation of the classic PsExec serviceindex=windows sourcetype="WinEventLog:System" EventCode=7045 ServiceName="PSEXESVC"| table _time, host, ServiceName, ImagePath, User5. Mitigation
Section titled “5. Mitigation”To mitigate lateral movement via PsExec and similar SMB-based tools:
- Restrict Administrative Shares: Disable
ADMIN$andC$shares where not strictly required by IT operations. - Micro-Segmentation: Block workstation-to-workstation SMB traffic (Port 445). SMB traffic should logically flow only from workstations to designated file servers or domain controllers.
- LAPS Deployment: Implement Microsoft Local Administrator Password Solution (LAPS) to ensure local admin credentials cannot be reused across multiple endpoints (Pass-the-Hash).
References
Section titled “References”- MITRE ATT&CK: System Services: Service Execution (T1569.002)
- Microsoft Sysinternals: PsExec Documentation
- Related Artifact: Analyzing Event ID 4688 & Process Lineage