Hacktricks-skills scmexec-analysis
Analyze and understand SCMExec lateral movement techniques for security assessments. Use this skill when investigating Windows lateral movement, reviewing Service Control Manager abuse, analyzing SharpMove or similar tools, or when you need to understand how attackers create services to execute commands on remote systems. This skill helps with threat hunting, incident response, and security assessments involving Windows service-based command execution.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/windows-hardening/lateral-movement/scmexec/SKILL.MDSCMExec Analysis Skill
This skill helps security professionals understand, detect, and analyze SCMExec lateral movement techniques used in Windows environments.
What is SCMExec?
SCMExec is a lateral movement technique that abuses the Service Control Manager (SCM) to execute commands on remote Windows systems. Attackers create a service that runs a malicious command, which can bypass security controls like UAC and Windows Defender.
How It Works
- Service Creation: The attacker creates a new Windows service on the remote system
- Command Execution: The service is configured to run a specific command or payload
- Persistence: The service may remain on the system for persistence
- Privilege Escalation: Often requires administrative credentials on the target
Detection Indicators
Service Creation Events
- Event ID 7045: A new service was installed
- Event ID 7040: A service was changed
- Event ID 7046: A service was installed with a new service type
PowerShell/Command Line Indicators
commandssc.exe create
PowerShell cmdletNew-Service
commands modifying service registry keysreg add
Network Indicators
- SMB traffic to remote systems (port 445)
- RPC traffic (port 135)
- Service control manager communication patterns
File System Indicators
- New executable files in system directories
- Service binary paths pointing to unusual locations
- Temporary files in
or similar directories%TEMP%
Common Tools
SharpMove
A C# tool that implements various lateral movement techniques including SCMExec.
Example usage pattern:
SharpMove.exe action=scm computername=remote.host.local command="C:\windows\temp\payload.exe" servicename=WindowsDebug amsi=true
Parameters:
: Specifies SCMExec techniqueaction=scm
: Target systemcomputername
: Command or payload to executecommand
: Name of the service to createservicename
: Bypass AMSI (Antimalware Scan Interface)amsi=true
Other Tools
(Sysinternals - legitimate tool often abused)psexec
service commandswmic- PowerShell
cmdletNew-Service
command-line toolsc.exe
Defensive Recommendations
Monitoring
- Enable Service Creation Logging: Ensure Event ID 7045 is being captured
- Monitor Service Binary Paths: Alert on services pointing to unusual locations
- Track Remote Service Creation: Monitor for services created via remote connections
- Watch for Suspicious Service Names: Services with random or obfuscated names
Prevention
- Least Privilege: Limit administrative access to systems
- Network Segmentation: Restrict lateral movement between systems
- Application Whitelisting: Prevent unauthorized executables from running
- Disable Unnecessary Services: Reduce attack surface
- Enable Credential Guard: Protect credentials from theft
Response Actions
- Identify the Service: Use
orsc query
to find the malicious serviceGet-Service - Stop and Delete:
thensc stop <service>sc delete <service> - Remove Payload: Delete the executable or script being run
- Investigate Source: Determine how the attacker gained access
- Check for Persistence: Look for other persistence mechanisms
Investigation Commands
Find Recently Created Services
Get-EventLog -LogName System -EntryType Information -InstanceId 7045 -Newest 50
List All Services with Details
Get-Service | Select-Object Name, DisplayName, Status, StartType
Check Service Binary Path
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\<ServiceName> | Select-Object ImagePath
Find Services with Suspicious Paths
Get-Service | ForEach-Object { $path = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\$_.Name).ImagePath if ($path -match "temp|appdata|users.*documents") { Write-Output "Suspicious: $($_.Name) - $path" } }
Registry Keys to Monitor
- Service definitionsHKLM\SYSTEM\CurrentControlSet\Services\
- Service binary pathHKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\ImagePath
- Service startup typeHKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Start
Related Techniques
- DCOM/WMIC: Similar remote execution via Windows Management Instrumentation
- WMI Event Subscription: Persistence via WMI event subscriptions
- Scheduled Tasks: Alternative persistence and execution mechanism
- PsExec: Legitimate tool commonly abused for lateral movement
References
- MITRE ATT&CK: Service Execution (T1543.003)
- SharpMove GitHub
- Sysinternals PsExec
- Windows Service Control Manager
Usage Notes
This skill is intended for:
- Security professionals conducting authorized assessments
- Incident responders investigating compromises
- Threat hunters looking for lateral movement indicators
- Security engineers building detection capabilities
Always ensure you have proper authorization before testing or investigating systems.