你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

测试无代理恶意软件扫描警报

除了由基于代理的Defender for Endpoint 与 Defender for Cloud 集成提供的下一代反恶意软件保护之外,Defender for Servers Plan 2 还提供无代理恶意软件扫描,作为其无代理扫描功能的一部分。

本文介绍如何创建测试警报,以确保无代理恶意软件扫描按预期工作。

先决条件

  • 适用于服务器的 Defender 计划 2 已启用。
  • 该方案中已启用无代理扫描。

创建适用于 Linux 的测试文件

请使用以下步骤在Linux虚拟机(VM)上创建测试文件,并触发无代理恶意软件扫描警报。

  1. 打开 VM 上的终端窗口。

  2. 运行以下脚本创建并验证包含杀毒测试字符串的测试文件:

    # test string  
    TEST_STRING='$$89-barbados-dublin-damascus-notice-pulled-natural-31$$'  
    
    # File to be created  
    FILE_PATH="/tmp/virus_test_file.txt"  
    
    # Write the test string to the file  
    echo -n $TEST_STRING > $FILE_PATH  
    
    # Check if the file was created and contains the correct string  
    if [ -f "$FILE_PATH" ]; then  
        if grep -Fq "$TEST_STRING" "$FILE_PATH"; then  
            echo "Virus test file created and validated successfully."  
        else  
            echo "Virus test file does not contain the correct string."  
        fi  
    else  
        echo "Failed to create virus test file."  
    fi
    

该警报MDC_Test_File malware was detected (Agentless)会在24小时内出现在Defender for Cloud Alerts页面和Defender XDR门户中。

Linux Defender for Cloud中显示的测试警报的屏幕截图。

使用文本文档为Windows创建测试文件

请按照以下步骤创建一个 Windows 文本文件,触发无代理恶意软件扫描的测试警报。

  1. 在 VM 上创建文本文件。

  2. 将文本 $$89-barbados-dublin-damascus-notice-pulled-natural-31$$ 粘贴到文本文件中。 确保文本文件中没有额外的空格或行。

  3. 保存文件。

  4. 打开文件验证是否包含粘贴的测试字符串。

该警报MDC_Test_File malware was detected (Agentless)会在24小时内出现在Defender for Cloud Alerts页面和Defender XDR门户中。

由于创建的文本文件而在 Defender for Cloud for Windows 中显示的测试警报的屏幕截图。

使用 PowerShell 为Windows创建测试文件

请使用以下PowerShell步骤创建Windows测试文件并生成恶意软件扫描测试警报。

  1. 在 VM 上打开 PowerShell。

  2. 执行以下脚本。

# Virus test string
$TEST_STRING = '$$89-barbados-dublin-damascus-notice-pulled-natural-31$$'

# File to be created
$FILE_PATH = "C:\temp\virus_test_file.txt"

# Create "temp" directory if it does not exist
$DIR_PATH = "C:\temp"
if (!(Test-Path -Path $DIR_PATH)) {
   New-Item -ItemType Directory -Path $DIR_PATH
}

# Write the test string to the file without a trailing newline
[IO.File]::WriteAllText($FILE_PATH, $TEST_STRING)

# Check if the file was created and contains the correct string
if (Test-Path -Path $FILE_PATH) {
    $content = [IO.File]::ReadAllText($FILE_PATH)
    if ($content -eq $TEST_STRING) {
      Write-Host "Test file created and validated successfully."
    } else {
       Write-Host "Test file does not contain the correct string."
    }
} else {
    Write-Host "Failed to create test file."
}

该警报MDC_Test_File malware was detected (Agentless)会在24小时内出现在Defender for Cloud Alerts页面和Defender XDR门户中。

由于 PowerShell 脚本而在 Defender for Cloud for Windows 中显示的测试警报的屏幕截图。