Disable and Bypass Defender

Check if Defender is enabled

# Check if Defender is enabled
Get-MpComputerStatus
Get-MpComputerStatus | Select AntivirusEnabled

# Check if defensive modules are enabled
Get-MpComputerStatus | Select RealTimeProtectionEnabled, IoavProtectionEnabled,AntispywareEnabled | FL

# Check if tamper protection is enabled
Get-MpComputerStatus | Select IsTamperProtected,RealTimeProtectionEnabled | FL

Alternative Antivirus products

In some cases if it appears Defender is not enabled an alternative Antivirus solution may be in effect.

Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntivirusProduct

Decoding the value of ProductState to hex can help identify which Antivirus is enabled

From the values below anything that has a 10 starting from the fourth numerical position indicates On and anything else indicates Off. As below we can see BitDefender is enabled and Windows Defender is disabled.

Turning off features

Note: Disabling UAC is advisable before attempting to turn features off. In testing some changes prompted for user confirmation before allowing change.

Note: If Tamper protection is enabled you will not be able to turn off Defender by CMD or PowerShell. You can however, still create an exclusion.

Bypassing with Path Exclusions

With reference to above we see its possible to use PowerShell to exclude Windows Defender from taking action on certain paths, using path exclusions.

Running curl on a msfvenom payload where the output folder is outside of the defined exclusion path:

Running the same command again however, this time specifying the excluded path from Defender C:\temp we see Defender has not picked up the malware.

Over on the attackers machine we see the msfvenom payload has connected back. Under normal circumstances AV will have no issues discovering this msfvenom payload.

Firewall

Disable all Firewall profiles (Requires Admin privileges).

AMSI Bypass

Tools

Amsi.Fail: https://amsi.fail/

AMSITrigger: https://github.com/RythmStick/AMSITrigger

PowerShell snippets

Undetected Reverse Shells

Further AMSI Reading

URL: https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell

URL: https://amsi.fail/

Resources

Tamper Protection: https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/prevent-changes-to-security-settings-with-tamper-protection?view=o365-worldwide

Last updated