Persistence · Windows
sc.exe
Service Control command line
Creates, configures, starts, stops and deletes services, locally or remotely. Services run as SYSTEM and start at boot, so they are a classic persistence and remote execution method.
Legitimate use
Admins and installers use it to manage Windows services.
Subcommands
Creates a new service, with a binary path and start type.
HighChanges an existing service, for example its binary path (binpath) or start type.
HighStarts a service.
MediumStops a service. Stopping security or backup services is an impact step.
MediumDeletes a service, which can remove a short-lived remote exec service.
MediumLists or queries services. Used for discovery.
LowShows a service's configuration, including its binary path.
LowSets recovery actions, which can be abused to run a command on failure.
MediumThe command line the service runs, written as binpath= value. A shell, script host or a path in temp is a red flag.
HighService type, written as type= value. type= kernel installs a driver, which is used in BYOVD.
MediumCommand lines to worry about
- High
Service created to run a script host or payload
A new service whose binary is a shell, script host or a file in a writable path. Services run as SYSTEM at boot, so this is strong persistence. Check 7045.
Detection regex
\bsc(\.exe)?\s+(\\\\\S+\s+)?create\b.*binpath=\s*"?[^"]*(cmd|powershell|rundll32|mshta|wscript|cscript|\\temp\\|\\appdata\\|\\programdata\\) - High
Kernel driver service
A service configured as a kernel driver. An unsigned or known-vulnerable driver points to bring-your-own-vulnerable-driver. Pivot to code-integrity events.
Detection regex
\bsc(\.exe)?\s+config\b.*type=\s*kernel
Where it is recorded
- Security4688Process creation with the full command line, when command-line auditing is enabled.
- Sysmon1Process creation with command line, hashes and parent process.
- System7045A service was installed, with the service name, image path, start type and account.
- Security4697A service was installed (Security log equivalent, when audited).
- System7036Service entered the running or stopped state.
- System7040Service start type was changed.
Community detections
17 SigmaHQ rules for sc.exe. The explainer checks every pasted command line against all of them.
- HighAllow Service Access Using Security Descriptor Tampering Via Sc.EXE
Detects suspicious DACL modifications to allow access to a service from a suspicious trustee. This can be used to override access restrictions set by previous ACLs.
T1543.003by Nasreddine Bencherchali (Nextron Systems)
- HighDeny Service Access Using Security Descriptor Tampering Via Sc.EXE
Detects suspicious DACL modifications to deny access to a service that affects critical trustees. This can be used to hide services or make them unstoppable.
T1543.003by Jonhnathan Ribeiro, oscd.community
- HighDisable Windows Defender AV Security Monitoring
Detects attackers attempting to disable Windows Defender using Powershell
T1685by ok @securonix invrep-de, oscd.community, frack113
- HighPossible Privilege Escalation via Weak Service Permissions
Detection of sc.exe utility spawning by user with Medium integrity level to change service ImagePath or FailureCommand
T1574.011by Teymur Kheirkhabarov
- HighService DACL Abuse To Hide Services Via Sc.EXE
Detects usage of the "sc.exe" utility adding a new service with special permission seen used by threat actors which makes the service hidden and unremovable.
T1574.011by Andreas Hunkeler (@Karneades)
- HighSuspicious New Service Creation
Detects creation of a new service via "sc" command or the powershell "new-service" cmdlet with suspicious binary paths
T1543.003by Nasreddine Bencherchali (Nextron Systems)
- HighSuspicious Process By Web Server Process
Detects potentially suspicious processes being spawned by a web server process which could be the result of a successfully placed web shell or exploitation
T1505.003T1190by Thomas Patzke, Florian Roth (Nextron Systems), Zach Stanford @svch0st, Tim Shelton, Nasreddine Bencherchali (Nextron Systems)
- HighSuspicious Service Path Modification
Detects service path modification via the "sc" binary to a suspicious command or path
T1543.003by Victor Sergeev, oscd.community, Nasreddine Bencherchali (Nextron Systems)
- HighSuspicious Spool Service Child Process
Detects suspicious print spool service (spoolsv.exe) child processes.
T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)
- HighSuspicious Windows Service Tampering
Detects the usage of binaries such as 'net', 'sc' or 'powershell' in order to stop, pause, disable or delete critical or important Windows services such as AV, Backup, etc. As seen being used in some ransomware scripts
T1489T1685by Nasreddine Bencherchali (Nextron Systems), frack113 , X__Junior (Nextron Systems)
- MediumNew Kernel Driver Via SC.EXE
Detects creation of a new service (kernel driver) with the type "kernel"
T1543.003by Nasreddine Bencherchali (Nextron Systems)
- MediumRecon Information for Export with Command Prompt
Once established within a system or network, an adversary may use automated techniques for collecting internal data.
T1119by frack113
- MediumService Security Descriptor Tampering Via Sc.EXE
Detection of sc.exe utility adding a new service with special permission which hides that service.
T1574.011by Nasreddine Bencherchali (Nextron Systems)
- MediumService StartupType Change Via Sc.EXE
Detect the use of "sc.exe" to change the startup type of a service to "disabled" or "demand"
T1685by Nasreddine Bencherchali (Nextron Systems)
- LowInteresting Service Enumeration Via Sc.EXE
Detects the enumeration and query of interesting and in some cases sensitive services on the system via "sc.exe". Attackers often try to enumerate the services currently running on a system in order to find different attack vectors.
T1003by Swachchhanda Shrawan Poudel
- LowNew Service Creation Using Sc.EXE
Detects the creation of a new service using the "sc.exe" utility.
T1543.003by Timur Zinniatullin, Daniil Yugoslavskiy, oscd.community
- LowStop Windows Service Via Sc.EXE
Detects the stopping of a Windows service via the "sc.exe" utility
T1489by Jakob Weinzettl, oscd.community, Nasreddine Bencherchali (Nextron Systems)
Rules from SigmaHQ (rules/windows/process_creation), Detection Rule License (DRL) 1.1. Each rule links to its source and credits its authors.