Modify Registry
Adversaries may interact with the Windows Registry to aid in defense evasion, persistence, and execution. The Registry may be modified to hide configuration information or malicious payloads, disable security controls (e.g., enabling WDigest plaintext credential caching, disabling Windows Defender, enabling Office macros), establish persistence via run keys or services, and store C2 configuration data. Common tools include the built-in reg.exe utility, PowerShell registry cmdlets (Set-ItemProperty, New-Item), and direct Win32 API calls (RegSetValueEx, RegCreateKeyEx). Adversaries may also target remote registries over SMB using valid accounts, or employ null-byte prefix tricks to create pseudo-hidden keys invisible to standard utilities.
let SuspiciousPersistenceKeys = dynamic([
"\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
"\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
"\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
"\\SYSTEM\\CurrentControlSet\\Services",
"\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options"
]);
let DefenseEvasionKeys = dynamic([
"\\SYSTEM\\CurrentControlSet\\Control\\Lsa",
"\\SOFTWARE\\Policies\\Microsoft\\Windows Defender",
"\\SOFTWARE\\Microsoft\\Windows Defender",
"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
"\\SOFTWARE\\Microsoft\\Office",
"\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap"
]);
let SuspiciousProcesses = dynamic([
"powershell.exe", "pwsh.exe", "cmd.exe", "wscript.exe", "cscript.exe",
"mshta.exe", "rundll32.exe", "regsvr32.exe", "msbuild.exe", "wmic.exe",
"certutil.exe", "bitsadmin.exe", "installutil.exe", "reg.exe"
]);
DeviceRegistryEvents
| where Timestamp > ago(24h)
| where ActionType in ("RegistryValueSet", "RegistryKeyCreated")
| where RegistryKey has_any (SuspiciousPersistenceKeys) or RegistryKey has_any (DefenseEvasionKeys)
| extend IsSuspiciousProcess = InitiatingProcessFileName in~ (SuspiciousProcesses)
| extend IsPersistenceKey = RegistryKey has_any (SuspiciousPersistenceKeys)
| extend IsDefenseEvasionKey = RegistryKey has_any (DefenseEvasionKeys)
| extend IsWDigestEnable = RegistryKey has "Lsa" and RegistryValueName =~ "UseLogonCredential" and RegistryValueData == "1"
| extend IsDefenderDisable = RegistryKey has "Windows Defender" and RegistryValueName =~ "DisableAntiSpyware" and RegistryValueData == "1"
| extend IsMacroEnable = RegistryKey has "\\Security" and RegistryValueName =~ "VBAWarnings" and RegistryValueData == "1"
| extend IsUACBypass = RegistryKey has "Policies\\System" and RegistryValueName =~ "EnableLUA" and RegistryValueData == "0"
| extend IsIFEO = RegistryKey has "Image File Execution Options" and RegistryValueName =~ "Debugger"
| extend IsWinlogonHijack = RegistryKey has "Winlogon" and RegistryValueName in~ ("Userinit", "Shell")
| project Timestamp, DeviceName, AccountName, ActionType,
RegistryKey, RegistryValueName, RegistryValueData,
InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessParentFileName,
IsPersistenceKey, IsDefenseEvasionKey, IsSuspiciousProcess,
IsWDigestEnable, IsDefenderDisable, IsMacroEnable, IsUACBypass, IsIFEO, IsWinlogonHijack
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Software installation and update processes legitimately modify Run keys and service registry entries — filter by known installer parent processes (msiexec.exe, setup.exe with code-signed paths)
- Group Policy application (gpsvc, gpscript.exe) modifies Defender and Office macro policy keys during scheduled policy refreshes
- System administrators using reg.exe or PowerShell to apply configuration baselines as part of hardening scripts
- Endpoint management agents (SCCM, Intune, Tanium) that configure system settings via registry modifications during software deployment
- Antivirus and EDR products that legitimately modify Windows Defender registry keys during updates or configuration changes
References (12)
- https://attack.mitre.org/techniques/T1112/
- https://learn.microsoft.com/en-us/sysinternals/downloads/reghide
- https://learn.microsoft.com/en-us/sysinternals/downloads/regdelnull
- https://technet.microsoft.com/en-us/library/cc732643.aspx
- https://technet.microsoft.com/en-us/library/cc754820.aspx
- https://docs.microsoft.com/windows/security/threat-protection/auditing/event-4657
- https://posts.specterops.io/hiding-registry-keys-with-psreflect-b18ec5ac8353
- https://blog.trendmicro.com/trendlabs-security-intelligence/poweliks-malware-hides-in-windows-registry/
- https://unit42.paloaltonetworks.com/new-babyshark-malware-targets-u-s-national-security-think-tanks/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1112/T1112.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/registry
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceregistryevents-table
Unlock Pro Content
Get the full detection package for T1112 including response playbook, investigation guide, and atomic red team tests.