Skip to content
WETNav

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.

Worst caseHigh

Subcommands

create

Creates a new service, with a binary path and start type.

High
config

Changes an existing service, for example its binary path (binpath) or start type.

High
start

Starts a service.

Medium
stop

Stops a service. Stopping security or backup services is an impact step.

Medium
delete

Deletes a service, which can remove a short-lived remote exec service.

Medium
query

Lists or queries services. Used for discovery.

Low
qc

Shows a service's configuration, including its binary path.

Low
failure

Sets recovery actions, which can be abused to run a command on failure.

Medium
binpath<value>

The command line the service runs, written as binpath= value. A shell, script host or a path in temp is a red flag.

High
type<value>

Service type, written as type= value. type= kernel installs a driver, which is used in BYOVD.

Medium

Command 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\\)

    T1543.003

  • High

    Remote service operation

    sc targets a remote host (\\host). Creating or starting a service remotely is a known lateral movement method, as used by PsExec-style tools.

    Detection regex\bsc(\.exe)?\s+\\\\\S+\s+(create|config|start)\b

    T1543.003T1021.002

  • 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

    T1543.003

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.

  • High
    Allow 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)

  • High
    Deny 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

  • High
    Disable Windows Defender AV Security Monitoring

    Detects attackers attempting to disable Windows Defender using Powershell

    T1685by ok @securonix invrep-de, oscd.community, frack113

  • High
    Possible 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

  • High
    Service 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)

  • High
    Suspicious 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)

  • High
    Suspicious 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)

  • High
    Suspicious 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)

  • High
    Suspicious Spool Service Child Process

    Detects suspicious print spool service (spoolsv.exe) child processes.

    T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)

  • High
    Suspicious 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)

  • Medium
    New Kernel Driver Via SC.EXE

    Detects creation of a new service (kernel driver) with the type "kernel"

    T1543.003by Nasreddine Bencherchali (Nextron Systems)

  • Medium
    Recon 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

  • Medium
    Service 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)

  • Medium
    Service 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)

  • Low
    Interesting 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

  • Low
    New 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

  • Low
    Stop 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.