Something interesting I've come across, admittedly only a handful of times, is that the `MpPreference` cmdlet is being used in nefarious ways. Specifically, this involves instances where Domain Admin accounts have been compromised, and they are being to create exclusions that bypass Windows Defender detections.
The `MpPreference` cmdlet family is related to Windows Defender. There are 12 different cmdlets in this family, but I've really only encountered `Add-MpPreference` in the wild. On that note, this is not referring to Windows Defender for Endpoint, ATP, or whatever it was called before that.
One important aspect of using MpPreference is that it requires some form of an elevated account to create the exclusions.
I first came across this technique when I observed a script being executed after a DA pushed a GPO that did a few interesting things. This script disabled AVs, EDRs, backups, grabbed a malicious executable from a network share, and cleared audit logs. The fact that the script also disabled Windows Defender caught my attention, as this was not a common occurrence or really something I was aware of at the time.
There are four different exclusions that can be used with the Add-MpPreference cmdlet:
- ExclusionExtension
- ExclusionIP
- ExclusionPath
- ExclusionProcess
An attacker can now use the `Add-MpPreference` cmdlet to write any extension, path, process, or IP to these locations; bypassing Windows Defender. I conducted a search to determine if this technique was being used in the wild, and I found one instance of an administrator using a third-party file backup software.
This led me to the idea of enumerating any previously written exclusions in an environment and then writing to them to bypass Defender. Which can be accomplished through Get-MpPreference and doesn't require an elevated account to use. A simple and likely undetected PowerShell script, such as the one shown below, could be used for this purpose:
Get-MpPreference | Select-Object -Property ExclusionExtension,ExclusionPath,ExclusionProcess,ExclusionIP | Format-table -Wrap
Because these exclusions cover multiple different areas, there are no restrictions on writing to these. An attacker with knowledge of any of these exclusions would be able to execute arbitrary files from here and evade defender. Therefore, it's important to verify any use of the `MpPreference` cmdlets, including the applications that are written and the account being used.
Solo + Finn 23
Comments
Post a Comment