|
| 1 | +--- |
| 2 | +title: AMSI demonstrations with Microsoft Defender for Endpoint |
| 3 | +description: Demonstration of AMSI detection by Microsoft Defender for Endpoint |
| 4 | +author: denisebmsft |
| 5 | +ms.author: deniseb |
| 6 | +ms.reviewer: yongrhee |
| 7 | +ms.service: defender-endpoint |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 09/30/2024 |
| 10 | +ms.subservice: ngp |
| 11 | +--- |
| 12 | + |
| 13 | +# AMSI demonstrations with Microsoft Defender for Endpoint |
| 14 | + |
| 15 | +**Applies to:** |
| 16 | + |
| 17 | +- [Microsoft Defender for Endpoint Plan 2](microsoft-defender-endpoint.md) |
| 18 | +- [Microsoft Defender for Business](https://www.microsoft.com/security/business/endpoint-security/microsoft-defender-business) |
| 19 | +- [Microsoft Defender for Endpoint Plan 1](microsoft-defender-endpoint.md) |
| 20 | + |
| 21 | +- [Microsoft Defender Antivirus](microsoft-defender-antivirus-windows.md) |
| 22 | + |
| 23 | +Microsoft Defender for Endpoint utilizes the [Antimalware Scan Interface (AMSI)](/defender-endpoint/amsi-on-mdav) to enhance protection against fileless malware, dynamic script-based attacks, and other nontraditional cyber threats. In this article, we describe how to test the AMSI engine with a benign sample. |
| 24 | + |
| 25 | +## Scenario requirements and setup |
| 26 | + |
| 27 | +- Windows 10 or newer |
| 28 | + |
| 29 | +- Windows Server 2016, or newer |
| 30 | + |
| 31 | +- Microsoft Defender Antivirus (as primary) and these need to be enabled: |
| 32 | + |
| 33 | + - Real-Time Protection (RTP) |
| 34 | + |
| 35 | + - Behavior Monitoring (BM) |
| 36 | + |
| 37 | + - Turn on script scanning |
| 38 | + |
| 39 | + |
| 40 | +## Testing AMSI |
| 41 | + |
| 42 | +In this demonstration page, you have three engine choices to test AMSI: |
| 43 | + |
| 44 | +- PowerShell |
| 45 | +- VBScript |
| 46 | + |
| 47 | +### Testing AMSI with PowerShell |
| 48 | + |
| 49 | + |
| 50 | +```powershell |
| 51 | +# Save this sample AMSI powershell script as AMSI_PoSh_script.ps1 |
| 52 | +$testString = "AMSI Test Sample: " + "7e72c3ce-861b-4339-8740-0ac1484c1386" |
| 53 | +Invoke-Expression $testString |
| 54 | +``` |
| 55 | + |
| 56 | +1. As an administrator, open PowerShell. |
| 57 | + |
| 58 | +2. Type `Powershell -ExecutionPolicy Bypass AMSI_PoSh_script.ps1`, and then press **Enter**. |
| 59 | + |
| 60 | + The result should be as follows: |
| 61 | + |
| 62 | + ```powershell |
| 63 | + Invoke-Expression : At line:1 char:1 |
| 64 | +
|
| 65 | + + AMSI Test Sample: 7e72c3ce-861b-4339-8740-0ac1484c1386 |
| 66 | +
|
| 67 | + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 68 | +
|
| 69 | + This script contains malicious content and has been blocked by your antivirus software. |
| 70 | +
|
| 71 | + At C:\Users\Admin\Desktop\AMSI_PoSh_script.ps1:3 char:1 |
| 72 | +
|
| 73 | + + Invoke-Expression $testString |
| 74 | +
|
| 75 | + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 76 | +
|
| 77 | + + CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException |
| 78 | +
|
| 79 | + + FullyQualifiedErrorId : ScriptContainedMaliciousContent,Microsoft.PowerShell.Commands.InvokeExpressionCommand |
| 80 | + |
| 81 | + ``` |
| 82 | +
|
| 83 | +
|
| 84 | +### Testing AMSI with VBScript |
| 85 | +
|
| 86 | +```vbscript |
| 87 | +
|
| 88 | +REM Save this sample AMSI vbscript as AMSI_vbscript.vbs |
| 89 | +Dim result |
| 90 | +result = eval("AMSI Test Sample: " + "7e72c3ce-861b-4339-8740-0ac1484c1386") |
| 91 | +WScript.Echo result |
| 92 | +
|
| 93 | +``` |
| 94 | + |
| 95 | +1. Open Command Prompt as an administrator. |
| 96 | + |
| 97 | +2. Type `wscript AMSI_vbscript.js`, and then press **Enter**. |
| 98 | + |
| 99 | + The result should be as follows: |
| 100 | + |
| 101 | + ```console |
| 102 | + |
| 103 | + Windows Script Host |
| 104 | + |
| 105 | + Script: C:\Users\Admin\Desktop\AMSI_vbscript.vbs |
| 106 | + |
| 107 | + Line: 3 |
| 108 | + |
| 109 | + Char: 1 |
| 110 | + |
| 111 | + Error: This script contains malicious content and has been blocked by your antivirus software.: 'eval' |
| 112 | + |
| 113 | + Code: 800A802D |
| 114 | + |
| 115 | + Source: Microsoft VBScript runtime error |
| 116 | + |
| 117 | + ``` |
| 118 | + |
| 119 | +### Verifying the test results |
| 120 | + |
| 121 | +In your protection history, you should be able to see the following information: |
| 122 | + |
| 123 | +```console |
| 124 | + |
| 125 | +Threat blocked |
| 126 | + |
| 127 | +Detected: Virus: Win32/MpTest!amsi |
| 128 | + |
| 129 | +Status: Cleaned |
| 130 | + |
| 131 | +This threat or app was cleaned or quarantined before it became active on your device. |
| 132 | + |
| 133 | +Details: This program is dangerous and replicates by infecting other files. |
| 134 | + |
| 135 | +Affected items: |
| 136 | + |
| 137 | +amsi: \Device\HarddiskVolume3\Windows\System32\WindowsPowershell\v1.0\powershell.exe |
| 138 | + |
| 139 | +or |
| 140 | + |
| 141 | +amsi: C:\Users\Admin\Desktop\AMSI_vbscript.vbs |
| 142 | + |
| 143 | +and/or you might see: |
| 144 | + |
| 145 | +Threat blocked |
| 146 | + |
| 147 | +Detected: Virus: Win32/MpTest!amsi |
| 148 | + |
| 149 | +Status: Cleaned |
| 150 | + |
| 151 | +This threat or app was cleaned or quarantined before it became active on your device. |
| 152 | + |
| 153 | +Details: This program is dangerous and replicates by infecting other files |
| 154 | + |
| 155 | +Affected items: |
| 156 | + |
| 157 | +``` |
| 158 | + |
| 159 | +### Get the list of Microsoft Defender Antivirus threats |
| 160 | + |
| 161 | +You can view detected threats by using the Event log or PowerShell. |
| 162 | + |
| 163 | +#### Use the Event log |
| 164 | + |
| 165 | +1. Go to **Start**, and search for `EventVwr.msc`. Open Event Viewer in the list of results. |
| 166 | + |
| 167 | +2. Go to **Applications and Services Logs** > **Microsoft** > **Windows** > **Windows Defender operational events**. |
| 168 | + |
| 169 | +3. Look for `event ID 1116`. You should see the following information: |
| 170 | + |
| 171 | + ```console |
| 172 | + |
| 173 | + Microsoft Defender Antivirus has detected malware or other potentially unwanted software. |
| 174 | + |
| 175 | + For more information please see the following: https://go.microsoft.com/fwlink/?linkid=37020&name=Virus:Win32/MpTest!amsi&threatid=2147694217&enterprise=0 |
| 176 | + |
| 177 | + Name: Virus:Win32/MpTest!amsi |
| 178 | + |
| 179 | + ID: 2147694217 |
| 180 | + |
| 181 | + Severity: Severe |
| 182 | + |
| 183 | + Category: Virus |
| 184 | + |
| 185 | + Path: _\Device\HarddiskVolume3\Windows\System32\WindowsPowerShell\v1.0\powershell.exe or _C:\Users\Admin\Desktop\AMSI_jscript.js; file: _C:\Users\Admin\Desktop\AMSI_jscript.js->[Eval] or _C:\Users\Admin\Desktop\AMSI_vbscript.vbs |
| 186 | + |
| 187 | + Detection Origin: Local machine or Unknown |
| 188 | + |
| 189 | + Detection Type: Concrete |
| 190 | + |
| 191 | + Detection Source: System |
| 192 | + |
| 193 | + User: NT AUTHORITY\SYSTEM |
| 194 | + |
| 195 | + Process Name: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe or C:\Windows\System32\cscript.exe or C:\Windows\System32\wscript.exe or Unknown |
| 196 | + |
| 197 | + Security intelligence Version: AV: 1.419.221.0, AS: 1.419.221.0, NIS: 1.419.221.0 |
| 198 | + |
| 199 | + Engine Version: AM: 1.1.24080.9, NIS: 1.1.24080.9 |
| 200 | + |
| 201 | + ``` |
| 202 | + |
| 203 | +##### Use PowerShell |
| 204 | + |
| 205 | +Open PowerShell, and then type the following command: `Get-MpThreat`. |
| 206 | + |
| 207 | +You might see the following results: |
| 208 | + |
| 209 | +```console |
| 210 | + |
| 211 | +CategoryID : 42 |
| 212 | + |
| 213 | +DidThreatExecute : True |
| 214 | + |
| 215 | +IsActive : True |
| 216 | + |
| 217 | +Resources : |
| 218 | + |
| 219 | +RollupStatus : 97 |
| 220 | + |
| 221 | +SchemaVersion : 1.0.0.0 |
| 222 | + |
| 223 | +SeverityID : 5 |
| 224 | + |
| 225 | +ThreatID : 2147694217 |
| 226 | + |
| 227 | +ThreatName : Virus:Win32/MpTest!amsi |
| 228 | + |
| 229 | +TypeID : 0 |
| 230 | + |
| 231 | +PSComputerName : |
| 232 | + |
| 233 | +``` |
| 234 | + |
| 235 | +## See also |
| 236 | + |
| 237 | +[Microsoft Defender for Endpoint - demonstration scenarios](defender-endpoint-demonstrations.md) |
| 238 | + |
| 239 | +[!INCLUDE [Microsoft Defender for Endpoint Tech Community](../includes/defender-mde-techcommunity.md)] |
0 commit comments