Detection rule
Potential Tampering With RDP Related Registry Keys Via Reg.EXE
Overview
Detects the execution of "reg.exe" for enabling/disabling the RDP service on the host by tampering with the 'CurrentControlSet\Control\Terminal Server' values
- Rule id
0d5675be-bc88-4172-86d3-1e96a4476536- ATT&CK techniques
- T1021.001 Remote Services: Remote Desktop Protocol, T1112 Modify Registry
- Severity
- High
- Confidence
- Low
- Origin
- SigmaHQ (community)
- SigmaHQ status
test- Used in defense packs
- n0n, The Gentlemen, qilin, INC Ransom, Akira, safepay, Play, everest, nightspire
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; 3 of 3 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) · 0d5675be-bc88-4172-86d3-1e96a4476536
title: Potential Tampering With RDP Related Registry Keys Via Reg.EXE
id: 0d5675be-bc88-4172-86d3-1e96a4476536
status: test
description: Detects the execution of "reg.exe" for enabling/disabling the RDP service on the host by tampering with the 'CurrentControlSet\Control\Terminal Server' values
references:
- https://thedfirreport.com/2022/02/21/qbot-and-zerologon-lead-to-full-domain-compromise/
- http://etutorials.org/Microsoft+Products/microsoft+windows+server+2003+terminal+services/Chapter+6+Registry/Registry+Keys+for+Terminal+Services/ # Contain description for most of the keys mentioned here (check it out if you want more information
- http://woshub.com/rds-shadow-how-to-connect-to-a-user-session-in-windows-server-2012-r2/ # Related to the Shadow RPD technique
- https://admx.help/HKLM/SOFTWARE/Policies/Microsoft/Windows%20NT/Terminal%20Services # Contain description for most of the keys mentioned here (check it out if you want more information)
- https://bazaar.abuse.ch/sample/6f3aa9362d72e806490a8abce245331030d1ab5ac77e400dd475748236a6cc81/
- https://blog.sekoia.io/darkgate-internals/
- https://blog.talosintelligence.com/understanding-the-phobos-affiliate-structure/
- https://github.com/redcanaryco/atomic-red-team/blob/02c7d02fe1f1feb0fc7944550408ea8224273994/atomics/T1112/T1112.md#atomic-test-63---disable-remote-desktop-anti-alias-setting-through-registry
- https://github.com/redcanaryco/atomic-red-team/blob/02c7d02fe1f1feb0fc7944550408ea8224273994/atomics/T1112/T1112.md#atomic-test-64---disable-remote-desktop-security-settings-through-registry
- https://github.com/redcanaryco/atomic-red-team/blob/dd526047b8c399c312fee47d1e6fb531164da54d/atomics/T1112/T1112.yaml#L790
- https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-terminalservices-rdp-winstationextensions-securitylayer
- https://threathunterplaybook.com/hunts/windows/190407-RegModEnableRDPConnections/notebook.html
- https://twitter.com/SagieSec/status/1469001618863624194?t=HRf0eA0W1YYzkTSHb-Ky1A&s=03 # Related to the Shadow RPD technique
- https://web.archive.org/web/20200929062532/https://blog.menasec.net/2019/02/threat-hunting-rdp-hijacking-via.html # Related to RDP hijacking via the "ServiceDll" key
- https://www.trendmicro.com/en_us/research/25/i/unmasking-the-gentlemen-ransomware.html
author: pH-T (Nextron Systems), @Kostastsale, TheDFIRReport
date: 2022-02-12
modified: 2025-11-22
tags:
- attack.persistence
- attack.lateral-movement
- attack.defense-impairment
- attack.t1021.001
- attack.t1112
logsource:
product: windows
category: process_creation
detection:
selection_main_img:
- Image|endswith: '\reg.exe'
- OriginalFileName: 'reg.exe'
selection_main_cli:
CommandLine|contains|all:
- ' add '
- '\CurrentControlSet\Control\Terminal Server'
- 'REG_DWORD'
- ' /f'
selection_values_1:
CommandLine|contains|all:
- 'Licensing Core'
- 'EnableConcurrentSessions'
selection_values_2:
CommandLine|contains:
- 'AllowTSConnections'
- 'fDenyTSConnections'
- 'fEnableWinStation'
- 'fSingleSessionPerUser'
- 'IdleWinStationPoolCount'
- 'MaxInstanceCount'
- 'SecurityLayer'
- 'TSAdvertise'
- 'TSAppCompat'
- 'TSEnabled'
- 'TSUserEnabled'
- 'WinStations\RDP-Tcp'
filter_main_values_tls:
CommandLine|contains|all:
- 'SecurityLayer'
- '02' # TLS Enabled
condition: all of selection_main_* and 1 of selection_values_* and not 1 of filter_main_*
falsepositives:
- Unknown
level: high
regression_tests_path: regression_data/rules/windows/process_creation/proc_creation_win_reg_rdp_keys_tamper/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 '% add %' AND LOWER(Command) LIKE '%\currentcontrolset\control\terminal server%' AND LOWER(Command) LIKE '%reg_dword%' AND LOWER(Command) LIKE '% /f%')) AND ((LOWER(Command) LIKE '%licensing core%' AND LOWER(Command) LIKE '%enableconcurrentsessions%') OR (LOWER(Command) LIKE '%allowtsconnections%' OR LOWER(Command) LIKE '%fdenytsconnections%' OR LOWER(Command) LIKE '%fenablewinstation%' OR LOWER(Command) LIKE '%fsinglesessionperuser%' OR LOWER(Command) LIKE '%idlewinstationpoolcount%' OR LOWER(Command) LIKE '%maxinstancecount%' OR LOWER(Command) LIKE '%securitylayer%' OR LOWER(Command) LIKE '%tsadvertise%' OR LOWER(Command) LIKE '%tsappcompat%' OR LOWER(Command) LIKE '%tsenabled%' OR LOWER(Command) LIKE '%tsuserenabled%' OR LOWER(Command) LIKE '%winstations\rdp-tcp%')) AND (NOT((LOWER(Command) LIKE '%securitylayer%' AND Command LIKE '%02%')))QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Potential Tampering With RDP Related Registry Keys Via Reg.EXE- 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:Potential Tampering With RDP Related Registry Ke:selection_main_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:Potential Tampering With RDP Related Registry Ke:selection_main_cli(match)All test lines must match (AND).Commandcontains:add,\CurrentControlSet\Control\Terminal Server,REG_DWORD,/f
BB:OffSet7:Potential Tampering With RDP Related Registry Ke:selection_values_1(match)All test lines must match (AND).Commandcontains:Licensing Core,EnableConcurrentSessions
BB:OffSet7:Potential Tampering With RDP Related Registry Ke:selection_values_2(match)All test lines must match (AND).Commandcontains:AllowTSConnections,fDenyTSConnections,fEnableWinStation,fSingleSessionPerUser,IdleWinStationPoolCount,MaxInstanceCount,SecurityLayer,TSAdvertise,TSAppCompat,TSEnabled,TSUserEnabled,WinStations\RDP-Tcp
BB:OffSet7:Potential Tampering With RDP Related Registry Ke:filter_main_values_tls(exclusion)All test lines must match (AND).Commandcontains:SecurityLayer,02
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:Potential Tampering With RDP Related Registry Ke:selection_main_img, BB:OffSet7:Potential Tampering With RDP Related Registry Ke:selection_main_cli]) AND (ANY of [BB:OffSet7:Potential Tampering With RDP Related Registry Ke:selection_values_1, BB:OffSet7:Potential Tampering With RDP Related Registry Ke:selection_values_2]) AND NOT (ANY of [BB:OffSet7:Potential Tampering With RDP Related Registry Ke:filter_main_values_tls])
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 '% add %' AND LOWER(Command) LIKE '%\currentcontrolset\control\terminal server%' AND LOWER(Command) LIKE '%reg_dword%' AND LOWER(Command) LIKE '% /f%')) AND ((LOWER(Command) LIKE '%licensing core%' AND LOWER(Command) LIKE '%enableconcurrentsessions%') OR (LOWER(Command) LIKE '%allowtsconnections%' OR LOWER(Command) LIKE '%fdenytsconnections%' OR LOWER(Command) LIKE '%fenablewinstation%' OR LOWER(Command) LIKE '%fsinglesessionperuser%' OR LOWER(Command) LIKE '%idlewinstationpoolcount%' OR LOWER(Command) LIKE '%maxinstancecount%' OR LOWER(Command) LIKE '%securitylayer%' OR LOWER(Command) LIKE '%tsadvertise%' OR LOWER(Command) LIKE '%tsappcompat%' OR LOWER(Command) LIKE '%tsenabled%' OR LOWER(Command) LIKE '%tsuserenabled%' OR LOWER(Command) LIKE '%winstations\rdp-tcp%')) AND (NOT((LOWER(Command) LIKE '%securitylayer%' AND Command LIKE '%02%')))
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="* add *" CommandLine="*\\CurrentControlSet\\Control\\Terminal Server*" CommandLine="*REG_DWORD*" CommandLine="* /f*" ((CommandLine="*Licensing Core*" CommandLine="*EnableConcurrentSessions*") OR CommandLine IN ("*AllowTSConnections*", "*fDenyTSConnections*", "*fEnableWinStation*", "*fSingleSessionPerUser*", "*IdleWinStationPoolCount*", "*MaxInstanceCount*", "*SecurityLayer*", "*TSAdvertise*", "*TSAppCompat*", "*TSEnabled*", "*TSUserEnabled*", "*WinStations\\RDP-Tcp*")) NOT (CommandLine="*SecurityLayer*" CommandLine="*02*")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
[Potential Tampering With RDP Related Registry Keys Via Reg.EXE]
description = Detects the execution of "reg.exe" for enabling/disabling the RDP service on the host by tampering with the 'CurrentControlSet\Control\Terminal Server' values
search = (Image="*\\reg.exe" OR OriginalFileName="reg.exe") CommandLine="* add *" CommandLine="*\\CurrentControlSet\\Control\\Terminal Server*" CommandLine="*REG_DWORD*" CommandLine="* /f*" ((CommandLine="*Licensing Core*" CommandLine="*EnableConcurrentSessions*") OR CommandLine IN ("*AllowTSConnections*", "*fDenyTSConnections*", "*fEnableWinStation*", "*fSingleSessionPerUser*", "*IdleWinStationPoolCount*", "*MaxInstanceCount*", "*SecurityLayer*", "*TSAdvertise*", "*TSAppCompat*", "*TSEnabled*", "*TSUserEnabled*", "*WinStations\\RDP-Tcp*")) NOT (CommandLine="*SecurityLayer*" CommandLine="*02*")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 " add " and TargetProcessCommandLine contains "\\CurrentControlSet\\Control\\Terminal Server" and TargetProcessCommandLine contains "REG_DWORD" and TargetProcessCommandLine contains " /f")) and ((TargetProcessCommandLine contains "Licensing Core" and TargetProcessCommandLine contains "EnableConcurrentSessions") or (TargetProcessCommandLine contains "AllowTSConnections" or TargetProcessCommandLine contains "fDenyTSConnections" or TargetProcessCommandLine contains "fEnableWinStation" or TargetProcessCommandLine contains "fSingleSessionPerUser" or TargetProcessCommandLine contains "IdleWinStationPoolCount" or TargetProcessCommandLine contains "MaxInstanceCount" or TargetProcessCommandLine contains "SecurityLayer" or TargetProcessCommandLine contains "TSAdvertise" or TargetProcessCommandLine contains "TSAppCompat" or TargetProcessCommandLine contains "TSEnabled" or TargetProcessCommandLine contains "TSUserEnabled" or TargetProcessCommandLine contains "WinStations\\RDP-Tcp")) and (not((TargetProcessCommandLine contains "SecurityLayer" and TargetProcessCommandLine contains "02")))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 " add " and ProcessCommandLine contains "\\CurrentControlSet\\Control\\Terminal Server" and ProcessCommandLine contains "REG_DWORD" and ProcessCommandLine contains " /f")) and ((ProcessCommandLine contains "Licensing Core" and ProcessCommandLine contains "EnableConcurrentSessions") or (ProcessCommandLine contains "AllowTSConnections" or ProcessCommandLine contains "fDenyTSConnections" or ProcessCommandLine contains "fEnableWinStation" or ProcessCommandLine contains "fSingleSessionPerUser" or ProcessCommandLine contains "IdleWinStationPoolCount" or ProcessCommandLine contains "MaxInstanceCount" or ProcessCommandLine contains "SecurityLayer" or ProcessCommandLine contains "TSAdvertise" or ProcessCommandLine contains "TSAppCompat" or ProcessCommandLine contains "TSEnabled" or ProcessCommandLine contains "TSUserEnabled" or ProcessCommandLine contains "WinStations\\RDP-Tcp")) and (not((ProcessCommandLine contains "SecurityLayer" and ProcessCommandLine contains "02")))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:*\ add\ * AND process.command_line:*\\CurrentControlSet\\Control\\Terminal\ Server* AND process.command_line:*REG_DWORD* AND process.command_line:*\ \/f*)) AND ((process.command_line:*Licensing\ Core* AND process.command_line:*EnableConcurrentSessions*) OR (process.command_line:(*AllowTSConnections* OR *fDenyTSConnections* OR *fEnableWinStation* OR *fSingleSessionPerUser* OR *IdleWinStationPoolCount* OR *MaxInstanceCount* OR *SecurityLayer* OR *TSAdvertise* OR *TSAppCompat* OR *TSEnabled* OR *TSUserEnabled* OR *WinStations\\RDP\-Tcp*))) AND (NOT (process.command_line:*SecurityLayer* AND process.command_line:*02*))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:"* add *" and process.command_line:"*\\CurrentControlSet\\Control\\Terminal Server*" and process.command_line:"*REG_DWORD*" and process.command_line:"* /f*")) and ((process.command_line:"*Licensing Core*" and process.command_line:"*EnableConcurrentSessions*") or (process.command_line like~ ("*AllowTSConnections*", "*fDenyTSConnections*", "*fEnableWinStation*", "*fSingleSessionPerUser*", "*IdleWinStationPoolCount*", "*MaxInstanceCount*", "*SecurityLayer*", "*TSAdvertise*", "*TSAppCompat*", "*TSEnabled*", "*TSUserEnabled*", "*WinStations\\RDP-Tcp*"))) and (not (process.command_line:"*SecurityLayer*" and process.command_line:"*02*"))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 "* add *" and process.command_line like "*\\\\CurrentControlSet\\\\Control\\\\Terminal Server*" and process.command_line like "*REG_DWORD*" and process.command_line like "* /f*" and (process.command_line like "*Licensing Core*" and process.command_line like "*EnableConcurrentSessions*" or process.command_line like "*AllowTSConnections*" or process.command_line like "*fDenyTSConnections*" or process.command_line like "*fEnableWinStation*" or process.command_line like "*fSingleSessionPerUser*" or process.command_line like "*IdleWinStationPoolCount*" or process.command_line like "*MaxInstanceCount*" or process.command_line like "*SecurityLayer*" or process.command_line like "*TSAdvertise*" or process.command_line like "*TSAppCompat*" or process.command_line like "*TSEnabled*" or process.command_line like "*TSUserEnabled*" or process.command_line like "*WinStations\\\\RDP-Tcp*") and not (process.command_line like "*SecurityLayer*" and process.command_line like "*02*")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineImageOriginalFileName
False positives
- Unknown
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
- https://thedfirreport.com/2022/02/21/qbot-and-zerologon-lead-to-full-domain-compromise/
- https://admx.help/HKLM/SOFTWARE/Policies/Microsoft/Windows%20NT/Terminal%20Services
- https://bazaar.abuse.ch/sample/6f3aa9362d72e806490a8abce245331030d1ab5ac77e400dd475748236a6cc81/
- https://blog.sekoia.io/darkgate-internals/
- https://blog.talosintelligence.com/understanding-the-phobos-affiliate-structure/
- https://github.com/redcanaryco/atomic-red-team/blob/02c7d02fe1f1feb0fc7944550408ea8224273994/atomics/T1112/T1112.md#atomic-test-63---disable-remote-desktop-anti-alias-setting-through-registry
- https://github.com/redcanaryco/atomic-red-team/blob/02c7d02fe1f1feb0fc7944550408ea8224273994/atomics/T1112/T1112.md#atomic-test-64---disable-remote-desktop-security-settings-through-registry
- https://github.com/redcanaryco/atomic-red-team/blob/dd526047b8c399c312fee47d1e6fb531164da54d/atomics/T1112/T1112.yaml#L790
- https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-terminalservices-rdp-winstationextensions-securitylayer
- https://threathunterplaybook.com/hunts/windows/190407-RegModEnableRDPConnections/notebook.html
- https://twitter.com/SagieSec/status/1469001618863624194?t=HRf0eA0W1YYzkTSHb-Ky1A&s=03
- https://web.archive.org/web/20200929062532/https://blog.menasec.net/2019/02/threat-hunting-rdp-hijacking-via.html
- https://www.trendmicro.com/en_us/research/25/i/unmasking-the-gentlemen-ransomware.html
Author and attribution
- Author
- pH-T (Nextron Systems), @Kostastsale, TheDFIRReport
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_reg_rdp_keys_tamper.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2