T1070.009
Clear Persistence
Adversaries may clear artifacts associated with previously established persistence on a host system to remove evidence of their activity. This may involve various actions, such as removing services, deleting executables, modifying the registry, or other cleanup methods to prevent defenders from collecting evidence of their persistent presence. Adversaries may also delete accounts previously created to maintain persistence. In some instances, artifacts of persistence may be removed once an adversary's persistence executes in order to prevent errors with the new instance of the malware.
Microsoft Sentinel / Defender
kusto
let PersistenceRegistryKeys = dynamic([
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options",
"SYSTEM\\CurrentControlSet\\Services",
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache"
]);
// Detection 1: Registry key deletion in persistence locations
let RegistryDeletions = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where ActionType == "RegistryKeyDeleted" or ActionType == "RegistryValueDeleted"
| where RegistryKey has_any (PersistenceRegistryKeys)
| extend DetectionType = "PersistenceRegistryDeleted"
| project Timestamp, DeviceName, AccountName, ActionType, RegistryKey, RegistryValueName,
InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessId,
InitiatingProcessParentFileName, DetectionType;
// Detection 2: Service deletion via sc.exe or PowerShell
let ServiceDeletion = DeviceProcessEvents
| where Timestamp > ago(24h)
| where (
(FileName =~ "sc.exe" and ProcessCommandLine has_any ("delete", "stop")) or
(FileName =~ "powershell.exe" or FileName =~ "pwsh.exe") and ProcessCommandLine has_any ("Remove-Service", "sc.exe delete", "Stop-Service") or
(FileName =~ "cmd.exe" and ProcessCommandLine has "sc" and ProcessCommandLine has "delete")
)
| extend DetectionType = "ServiceDeletion"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Detection 3: Scheduled task deletion
let TaskDeletion = DeviceProcessEvents
| where Timestamp > ago(24h)
| where (
(FileName =~ "schtasks.exe" and ProcessCommandLine has "/delete") or
(FileName =~ "powershell.exe" or FileName =~ "pwsh.exe") and ProcessCommandLine has_any ("Unregister-ScheduledTask", "schtasks /delete")
)
| extend DetectionType = "ScheduledTaskDeleted"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Detection 4: User account deletion
let AccountDeletion = DeviceProcessEvents
| where Timestamp > ago(24h)
| where (
(FileName =~ "net.exe" or FileName =~ "net1.exe") and ProcessCommandLine has "user" and ProcessCommandLine has "/delete" or
(FileName =~ "powershell.exe" or FileName =~ "pwsh.exe") and ProcessCommandLine has_any ("Remove-LocalUser", "net user") and ProcessCommandLine has "/delete"
)
| extend DetectionType = "AccountDeleted"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Combine all detections
union RegistryDeletions, ServiceDeletion, TaskDeletion, AccountDeletion
| sort by Timestamp desc high severity
medium confidence
Data Sources
Windows Registry: Registry Key Deletion Process: Process Creation Scheduled Job: Scheduled Job Modification User Account: User Account Deletion Microsoft Defender for Endpoint
Required Tables
DeviceRegistryEvents DeviceProcessEvents
False Positives
- Software uninstallers legitimately removing their own Run/RunOnce registry entries during uninstallation
- IT administrators removing stale scheduled tasks, services, or user accounts during routine maintenance
- Endpoint security or patch management tools (SCCM, Intune, PDQ Deploy) that clean up their own persistence entries after completing tasks
- System cleanup tools (CCleaner, Windows built-in Disk Cleanup) removing startup entries as part of optimization
- Group Policy processing removing or updating startup registry entries during policy refresh
Last updated: 2026-04-13 Research depth: deep
References (11)
- https://attack.mitre.org/techniques/T1070/009/
- https://s7d2.scene7.com/is/content/cylance/prod/cylance-web/en-us/resources/knowledge-center/resource-library/reports/Op_Dust_Storm_Report.pdf
- https://blog.talosintelligence.com/recent-cyber-attack/
- https://research.nccgroup.com/2020/06/02/in-depth-analysis-of-the-new-team9-malware-family/
- https://www.microsoft.com/security/blog/2021/01/20/deep-dive-into-the-solorigate-second-stage-activation-from-sunburst-to-teardrop-and-raindrop/
- https://www.secureworks.com/research/mcmd-malware-analysis
- https://sentinelone.com/labs/from-wiper-to-ransomware-the-evolution-of-agrius/
- https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/pillowmint-fin7s-monkey-thief/
- https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4726
- https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4697
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
Unlock Pro Content
Get the full detection package for T1070.009 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance