Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Defender - Add exclusion folder programmatically

I was checking out different keyloggers for research purposes and stumbled upon Refog:

https://www.refog.com/keylogger/

This program could catch a lot of system events, but what really caught my attention was something else. The program created a hidden folder called Mpk, path C:\Windows\SysWOW64\Mpk. It was marked as an operating system files folder, because it was not visible until I unmarked Hide protected operating system files (recommended). This, I guess, can be done via the attrib command like this attrib +s +h "C:\Windows\SysWOW64\Mpk" so nothing revolutionary.

Hide

However they also added an exclusion to Windows Defender for this folder. How can they do this programmatically? I'm running Windows 10 Pro x64.

Exclusion

like image 377
Ogglas Avatar asked Oct 25 '16 06:10

Ogglas


People also ask

How do I add a folder to the defender exclusion list?

Go to Start > Settings > Update & Security > Windows Security > Virus & threat protection. Under Virus & threat protection settings, select Manage settings, and then under Exclusions, select Add or remove exclusions. Select Add an exclusion, and then select from files, folders, file types, or process.

How do I add exclusions to endpoint in Microsoft Defender?

In the Group Policy Management Editor go to Computer configuration, and select Administrative templates. Expand the tree to Windows components > Microsoft Defender Antivirus > Exclusions. Open the Path Exclusions setting for editing, and add your exclusions. Set the option to Enabled.

What is ADD-MpPreference?

Description. The Add-MpPreference cmdlet modifies settings for Windows Defender. Use this cmdlet to add exclusions for file name extensions, paths, and processes, and to add default actions for high, moderate, and low threats.


2 Answers

The correct way to do this is using the Add-MpPreference PowerShell cmdlet. Use this cmdlet to add exclusions for file name extensions, paths, and processes, and to add default actions for high, moderate, and low threats.

You can easily perform this from the elevated cmd shell in Windows 10 using the following command line:

powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath "C:\Windows\SysWOW64\Mpk"
like image 79
balrob Avatar answered Sep 18 '22 18:09

balrob


Run in elevated shell (search cmd in Start menu and hit Ctrl+Shift+Enter).

powershell -Command Add-MpPreference -ExclusionPath "C:\tmp"
powershell -Command Add-MpPreference -ExclusionProcess "java.exe"
powershell -Command Add-MpPreference -ExclusionExtension ".java"

powershell -Command Remove-MpPreference -ExclusionExtension ".java"
  • Add an exclusion to Windows Security
  • Modifies settings for Windows Defender from PowerShell
  • Removes exclusions or default actions
like image 26
gavenkoa Avatar answered Sep 19 '22 18:09

gavenkoa