Detection rule
Service StartupType Change Via PowerShell Set-Service
Overview
Detects the use of the PowerShell "Set-Service" cmdlet to change the startup type of a service to "disabled" or "manual"
- Rule id
62b20d44-1546-4e61-afce-8e175eb9473c- ATT&CK techniques
- T1685 Disable or Modify Tools
- Severity
- Medium
- Confidence
- Low
- Origin
- SigmaHQ (community)
- SigmaHQ status
test- Used in defense packs
- n0n, The Gentlemen, qilin, INC Ransom, Akira, safepay, Play, braincipher, majinahanashi
Validation
- ExperimentalSyntax checked only. Not yet tested on events.
- Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
- SIEM-validatedRun in a real SIEM, with a recorded result.
2 of 2 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.
Detection logic and queries
Queries are shown exactly as generated. Test them in your environment before you deploy them.
Sigma
Sigma (YAML) · 62b20d44-1546-4e61-afce-8e175eb9473c
title: Service StartupType Change Via PowerShell Set-Service
id: 62b20d44-1546-4e61-afce-8e175eb9473c
status: test
description: Detects the use of the PowerShell "Set-Service" cmdlet to change the startup type of a service to "disabled" or "manual"
references:
- https://www.virustotal.com/gui/file/38283b775552da8981452941ea74191aa0d203edd3f61fb2dee7b0aea3514955
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-03-04
tags:
- attack.execution
- attack.defense-impairment
- attack.t1685
logsource:
category: process_creation
product: windows
detection:
selection_img:
- Image|endswith: '\powershell.exe'
- OriginalFileName: 'PowerShell.EXE'
selection_cli:
CommandLine|contains|all:
- 'Set-Service'
- '-StartupType'
CommandLine|contains:
- 'Disabled'
- 'Manual'
condition: all of selection_*
falsepositives:
- False positives may occur with troubleshooting scripts
level: mediumQRadar AQL
IBM QRadar AQL (hunting query)Hunting query
Hunting search for the Log Activity tab or the API. It is not a QRadar rule.
AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).
SELECT * FROM events WHERE devicetype=12 AND ((LOWER("Process Path") LIKE '%\powershell.exe' OR LOWER("Process Name") LIKE '%\powershell.exe') OR Filename='PowerShell.EXE') AND ((LOWER(Command) LIKE '%set-service%' AND LOWER(Command) LIKE '%-startuptype%') AND (LOWER(Command) LIKE '%disabled%' OR LOWER(Command) LIKE '%manual%'))QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Service StartupType Change Via PowerShell Set-Service- Rule type
- Event rule (Local)
- Log source types
- Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1
Building blocks
BB:OffSet7:Service StartupType Change Via PowerShell Set Se:selection_img(match)Any of the groups matches (OR): build one BB per group and a parent BB "when an event matches any of" them.Process Path / Process Nameends with:\powershell.exeFilenameis equal to (case-insensitive):PowerShell.EXE
BB:OffSet7:Service StartupType Change Via PowerShell Set Se:selection_cli(match)All test lines must match (AND).Commandcontains:Set-Service,-StartupTypeCommandcontains:Disabled,Manual
Main rule, option A (building blocks)
- when the event(s) were detected by one or more of these log source types:
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1 - when an event matches the condition built from these building blocks:
(ALL of [BB:OffSet7:Service StartupType Change Via PowerShell Set Se:selection_img, BB:OffSet7:Service StartupType Change Via PowerShell Set Se:selection_cli])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND ((LOWER("Process Path") LIKE '%\powershell.exe' OR LOWER("Process Name") LIKE '%\powershell.exe') OR Filename='PowerShell.EXE') AND ((LOWER(Command) LIKE '%set-service%' AND LOWER(Command) LIKE '%-startuptype%') AND (LOWER(Command) LIKE '%disabled%' OR LOWER(Command) LIKE '%manual%'))
Rule response
- Severity 5, credibility 6, relevance 7
- Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
- Respond no more than once per 30 minutes per Log Source (tune per environment)
Limitations
- QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.
Splunk
Splunk SPLSearch
Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.
(Image="*\\powershell.exe" OR OriginalFileName="PowerShell.EXE") CommandLine="*Set-Service*" CommandLine="*-StartupType*" (CommandLine IN ("*Disabled*", "*Manual*"))Splunk savedsearches.conf stanzaScheduled search template
Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.
[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now
[Service StartupType Change Via PowerShell Set-Service]
description = Detects the use of the PowerShell "Set-Service" cmdlet to change the startup type of a service to "disabled" or "manual"
search = (Image="*\\powershell.exe" OR OriginalFileName="PowerShell.EXE") CommandLine="*Set-Service*" CommandLine="*-StartupType*" (CommandLine IN ("*Disabled*", "*Manual*"))Microsoft Sentinel
Microsoft Sentinel KQL (ASIM)Hunting query
Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.
imProcessCreate
| where (TargetProcessName endswith "\\powershell.exe" or TargetProcessFileOriginalName =~ "PowerShell.EXE") and ((TargetProcessCommandLine contains "Set-Service" and TargetProcessCommandLine contains "-StartupType") and (TargetProcessCommandLine contains "Disabled" or TargetProcessCommandLine contains "Manual"))Defender XDR
Microsoft Defender XDR KQLHunting query
Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.
DeviceProcessEvents
| where (FolderPath endswith "\\powershell.exe" or ProcessVersionInfoOriginalFileName =~ "PowerShell.EXE") and ((ProcessCommandLine contains "Set-Service" and ProcessCommandLine contains "-StartupType") and (ProcessCommandLine contains "Disabled" or ProcessCommandLine contains "Manual"))Elastic
Elastic Lucene (ECS)Hunting query
Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.
(process.executable:*\\powershell.exe OR process.pe.original_file_name:PowerShell.EXE) AND ((process.command_line:*Set\-Service* AND process.command_line:*\-StartupType*) AND (process.command_line:(*Disabled* OR *Manual*)))Elastic EQL (ECS)Hunting query
EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.
any where (process.executable:"*\\powershell.exe" or process.pe.original_file_name:"PowerShell.EXE") and ((process.command_line:"*Set-Service*" and process.command_line:"*-StartupType*") and (process.command_line like~ ("*Disabled*", "*Manual*")))Elastic ES|QL (ECS)Hunting query
ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.
from * metadata _id, _index, _version | where (ends_with(process.executable, "\\powershell.exe") or process.pe.original_file_name=="PowerShell.EXE") and process.command_line like "*Set-Service*" and process.command_line like "*-StartupType*" and (process.command_line like "*Disabled*" or process.command_line like "*Manual*")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineImageOriginalFileName
False positives
- False positives may occur with troubleshooting scripts
Investigation and response
No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.
References
Author and attribution
- Author
- Nasreddine Bencherchali (Nextron Systems)
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_powershell_set_service_disabled.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2