Detecting Privilege Escalation with Sysmon
Detecting Privilege Escalation with Sysmon
Privilege escalation is a critical stage in an attack, allowing adversaries to gain higher system privileges (e.g., NT AUTHORITY\SYSTEM) and execute malicious actions. Sysmon provides detailed monitoring capabilities to detect such activities by analyzing process executions, registry modifications, and network connections.
Common Privilege Escalation Techniques
1. Weak Service Permissions
Attack Vector: Exploiting weak service permissions to modify the service configuration.
Attack Steps:
Service Enumeration: Identify services with misconfigured permissions using tools like
accesschk
.Modify Service Configuration: Change the
ImagePath
to point to a malicious binary.Start the Service: Execute the binary with SYSTEM privileges.
Sysmon Detection:
Event ID 13 - Registry Modification: Tracks changes to service configurations in the registry (
ImagePath
).Event ID 1 - Process Creation: Logs the execution of malicious binaries.
Event ID 3 - Network Connection: Captures outbound connections from the malicious process.
Sample Sysmon Logs:
Registry Modification (Event ID 13):
Process Creation (Event ID 1):
Network Connection (Event ID 3):
2. Insecure Registry Permissions
Attack Vector: Modifying registry keys associated with services to execute malicious payloads.
Attack Steps:
Identify Insecure Registry Keys: Find registry keys with weak permissions.
Modify the
ImagePath
: Point the service to a malicious executable.Start the Service: Run the payload with SYSTEM privileges.
Sysmon Detection:
Event ID 13 - Registry Modification: Detects unauthorized changes to sensitive registry keys.
Sample Sysmon Logs:
Registry Modification (Event ID 13):
3. Metasploit getsystem
Command
getsystem
CommandAttack Vector: Using Metasploit’s built-in privilege escalation techniques.
Attack Steps:
Execute
getsystem
: Automatically applies privilege escalation techniques.Create Temporary Services: Leverage service creation to gain SYSTEM privileges.
Sysmon Detection:
Event ID 1 - Process Creation: Detects command-line executions.
Event ID 13 - Registry Modification: Tracks registry changes related to new or modified services.
Sample Sysmon Logs:
Process Creation (Event ID 1):
Registry Modification (Event ID 13):
Sysmon Event ID Summary for Privilege Escalation Detection
Event ID | Description | Use Case |
1 | Process Creation | Track execution of suspicious processes. |
13 | Registry Object Added/Deleted/Modified | Detect changes to critical registry keys (e.g., service |
3 | Network Connection | Identify outbound connections from escalated processes (e.g., reverse shells). |
Best Practices for Mitigating Privilege Escalation
Harden Service and Registry Permissions:
Regularly audit permissions on services and registry keys.
Use tools like
accesschk
to identify weak configurations.
Enable Sysmon with a Robust Configuration:
Use a tailored Sysmon configuration to monitor high-risk areas.
Filter noise by excluding known legitimate processes.
Integrate with SIEM:
Forward Sysmon logs to a SIEM for correlation and alerting.
Set up real-time alerts for critical Event IDs (1, 13, 3).
Monitor for Post-Exploitation Behavior:
Focus on lateral movement and privilege escalation indicators.
Combine Sysmon logs with other telemetry sources (e.g., Windows Event Logs).
Key Points
By leveraging Sysmon Event IDs and tailoring detection rules, security teams can effectively monitor and detect privilege escalation attempts. Combined with proactive auditing and real-time alerting, Sysmon provides robust visibility into malicious activities, enabling faster response and containment.
Last updated