Analyzing PsExec Lateral Movement Telemetry

Investigating Suspicious Rundll32.exe Executions: A Real-World Threat Hunting Case Study

Initial Detection and Hypothesis Formation

During our routine monitoring, we flagged an unusual pattern of activity on a Windows workstation. The Sysmon logs revealed multiple instances of rundll32.exe being executed with various arguments that caught our attention due to their potential for lateral movement and privilege escalation. This led us to hypothesize that adversaries might be abusing PsExec or similar tools to move laterally within the network while evading traditional endpoint visibility.

Process Lineage Analysis

To dive deeper, we began by tracing process lineage using Sysmon logs. We focused on key fields like Image, ParentProcessGuid, and CommandLine to map out any suspicious activity.

Analyzing Initial Logs

We ran a KQL query to identify processes with rundll32.exe in their command line:

DeviceProcessEvents
| where ProcessName has "rundll32.exe"
| project Timestamp, DeviceName, ProcessName, CommandLine, ParentProcessGuid

This returned several results that warranted further investigation. One particular execution stood out:

C:\Users\Temp\AppData\Local\tmpfile.dll -enc C:\Users\Temp\mal-ware.exe

The presence of tmpfile.dll and an encrypted pay-load (mal-ware.exe) raised significant red flags.

Expanding the Investigation

To understand if this was part of a broader attack, we expanded our investigation by reviewing other relevant telemetry such as Service Creation Logs and SMB Logs.

Reviewing Service Creation Logs

We checked for recent service creations that might be related to this activity:

Security | where EventID == "469" and TimeGenerated > ago(1h)

One entry stood out, created shortly before the suspicious command execution.

Analyzing SMB Logon Events

To get a better understanding of network communication, we looked at logon events using EventID 4624:

Security | where EventID == "4624" and TimeGenerated > ago(1h)

We identified several logon events that could be linked to the suspicious command execution.

Detection Opportunities

Based on our findings, we decided to generate a Sigma rule for detecting suspicious rundll32.exe usage:

Sigma Rule: Suspicious Rundll32 Usage

title: Suspicious Rundll32 Usage
logsource:
  category: process_creation
detection:
  selection:
    Image|endswith: 'rundll32.exe'
    CommandLine|contains: '-enc'
  condition: selection
level: medium

We also considered other potential detections, such as:

KQL Query for Suspicious Rundll32 Executions

DeviceProcessEvents
| where ProcessName has "rundll32.exe" and ProcessCommandLine contains "-enc"
| project Timestamp, DeviceName, ProcessName, CommandLine, ParentProcessGuid

SPL Query for Suspicious Rundll32 Executions

index=sysmon Image="*rundll32.exe"
| stats count by Computer, CommandLine

Analyst Observations

Uncertainty and False Positives

Not all suspicious commands are malicious. For example, an administrator might use rundll32.exe for legitimate purposes. However, the combination of a temporary directory, an encrypted pay-load, and the timing with other suspicious activities prompted us to investigate further.

Process Lineage Analysis

We found that rundll32.exe was often invoked by another process, which could be a sign of lateral movement or privilege escalation:

ParentProcess: C:\Windows\System32\explorer.exe (PID: 1234)
ChildProcess: C:\Users\Temp\AppData\Local\tmpfile.dll -enc C:\Users\Temp\mal-ware.exe (PID: 5678)

Telemetry Blind Spots

While our telemetry provided valuable insights, there were some blind spots:

  • Scheduled Tasks: We did not see any scheduled tasks or task plans that might have been used for automation.
  • Remote Connections: The rundll32.exe executions could be part of a remote connection, but we didn’t capture these events.

Operational Challenges

Realistic Troubleshooting

One challenge was ensuring that our logs were being collected and indexed properly. We had to verify the integrity of Sysmon logs by checking event IDs and timestamps against known good baselines.

Limitations of Detections

We realized that some detections might have limitations, such as false positives from legitimate administrative tasks or misconfigurations in logging policies.

Practical Hunting Methodology

Mitigation Strategies

Based on our findings, we recommended several mitigation strategies:

  • Monitor for Suspicious Commands: Implement a Sigma rule to detect rundll32.exe with -enc arguments.
  • Service Monitoring: Continuously monitor service creation logs for any anomalies.
  • Network Traffic Analysis: Use firewall and IDS/IPS rules to block suspicious network traffic.

Telemetry Improvement Ideas

To improve our telemetry, we suggested:

  • Enhanced Logging Policies: Ensure that all critical processes are logged with detailed information.
  • Behavioral Analytics: Implement machine learning models to detect anomalies in process behavior.
  • Endpoint Detection and Response (EDR): Deploy EDR tools to provide real-time visibility into endpoint activities.

MITRE ATT&CK Mapping

T1569.002: Lateral Movement via Remote Services

Our investigation mapped directly to the following MITRE ATT&CK techniques:

  • T1569.002: Remote Service Creation
    • The attacker created a service that could be used for remote access.
  • T1028.003: Remote Services
    • The use of rundll32.exe and temporary directories to execute malicious pay-loads.

T1569.004: Lateral Movement via Protocol

  • T1569.004: Lateral Communication
    • The attacker used protocols like SMB for communication, as seen in our network logs.

Conclusion

This investigation underscored the importance of detailed telemetry and process lineage analysis in detecting lateral movement techniques. By leveraging Sigma rules, KQL queries, and EDR tools, we were able to identify potential threats that could have gone unnoticed otherwise. Continuous improvement in logging policies and behavioral analytics will help us stay one step ahead of sophisticated adversaries.

Hashtags

PsExec #LateralMovement #MITREATT&CK #ThreatHunting #SecurityOperationsCenter #SysmonLogs #SigmaRules #KQLQueries #EDRTools


This case study provides a realistic example of how to conduct an in-depth investigation into potential lateral movement using PsExec, highlighting the importance of detailed telemetry and process lineage analysis.

#ThreatHunting #CyberSecurity #BlueTeam #SOC #DetectionEngineering #MITREATTACK #LateralMovement #Windows #PsExecLateralMovement