Detection rule
Add SafeBoot Keys Via Reg Utility
Overview
Detects execution of "reg.exe" commands with the "add" or "copy" flags on safe boot registry keys. Often used by attacker to allow the ransomware to work in safe mode as some security products do not
- Rule id
d7662ff6-9e97-4596-a61d-9839e32dee8d- ATT&CK techniques
- T1685 Disable or Modify Tools
- Severity
- High
- 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) · d7662ff6-9e97-4596-a61d-9839e32dee8d
title: Add SafeBoot Keys Via Reg Utility
id: d7662ff6-9e97-4596-a61d-9839e32dee8d
related:
- id: fc0e89b5-adb0-43c1-b749-c12a10ec37de
type: similar
status: test
description: Detects execution of "reg.exe" commands with the "add" or "copy" flags on safe boot registry keys. Often used by attacker to allow the ransomware to work in safe mode as some security products do not
references:
- https://redacted.com/blog/bianlian-ransomware-gang-gives-it-a-go/
author: Nasreddine Bencherchali (Nextron Systems)
date: 2022-09-02
modified: 2024-03-19
tags:
- attack.defense-impairment
- attack.t1685
logsource:
category: process_creation
product: windows
detection:
selection_img:
- Image|endswith: '\reg.exe'
- OriginalFileName: 'reg.exe'
selection_safeboot:
CommandLine|contains: '\SYSTEM\CurrentControlSet\Control\SafeBoot'
selection_flag:
CommandLine|contains:
- ' copy '
- ' add '
condition: all of selection*
falsepositives:
- Unlikely
level: high
regression_tests_path: regression_data/rules/windows/process_creation/proc_creation_win_reg_add_safeboot/info.ymlQRadar 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 '%\reg.exe' OR LOWER("Process Name") LIKE '%\reg.exe') OR Filename='reg.exe') AND LOWER(Command) LIKE '%\system\currentcontrolset\control\safeboot%' AND (LOWER(Command) LIKE '% copy %' OR LOWER(Command) LIKE '% add %')QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Add SafeBoot Keys Via Reg Utility- 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:Add SafeBoot Keys Via Reg Utility: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:\reg.exeFilenameis equal to (case-insensitive):reg.exe
BB:OffSet7:Add SafeBoot Keys Via Reg Utility:selection_safeboot(match)All test lines must match (AND).Commandcontains:\SYSTEM\CurrentControlSet\Control\SafeBoot
BB:OffSet7:Add SafeBoot Keys Via Reg Utility:selection_flag(match)All test lines must match (AND).Commandcontains:copy,add
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:Add SafeBoot Keys Via Reg Utility:selection_img, BB:OffSet7:Add SafeBoot Keys Via Reg Utility:selection_safeboot, BB:OffSet7:Add SafeBoot Keys Via Reg Utility:selection_flag])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND ((LOWER("Process Path") LIKE '%\reg.exe' OR LOWER("Process Name") LIKE '%\reg.exe') OR Filename='reg.exe') AND LOWER(Command) LIKE '%\system\currentcontrolset\control\safeboot%' AND (LOWER(Command) LIKE '% copy %' OR LOWER(Command) LIKE '% add %')
Rule response
- Severity 7, 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="*\\reg.exe" OR OriginalFileName="reg.exe") CommandLine="*\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot*" (CommandLine IN ("* copy *", "* add *"))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
[Add SafeBoot Keys Via Reg Utility]
description = Detects execution of "reg.exe" commands with the "add" or "copy" flags on safe boot registry keys. Often used by attacker to allow the ransomware to work in safe mode as some security products do not
search = (Image="*\\reg.exe" OR OriginalFileName="reg.exe") CommandLine="*\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot*" (CommandLine IN ("* copy *", "* add *"))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 "\\reg.exe" or TargetProcessFileOriginalName =~ "reg.exe") and TargetProcessCommandLine contains "\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot" and (TargetProcessCommandLine contains " copy " or TargetProcessCommandLine contains " add ")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 "\\reg.exe" or ProcessVersionInfoOriginalFileName =~ "reg.exe") and ProcessCommandLine contains "\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot" and (ProcessCommandLine contains " copy " or ProcessCommandLine contains " add ")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:*\\reg.exe OR process.pe.original_file_name:reg.exe) AND process.command_line:*\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot* AND (process.command_line:(*\ copy\ * OR *\ add\ *))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:"*\\reg.exe" or process.pe.original_file_name:"reg.exe") and process.command_line:"*\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot*" and (process.command_line like~ ("* copy *", "* add *"))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, "\\reg.exe") or process.pe.original_file_name=="reg.exe") and process.command_line like "*\\\\SYSTEM\\\\CurrentControlSet\\\\Control\\\\SafeBoot*" and (process.command_line like "* copy *" or process.command_line like "* add *")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineImageOriginalFileName
False positives
- Unlikely
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_reg_add_safeboot.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2