在 Linux 上运行客户端分析器
适用于:
希望体验 Defender for Endpoint? 注册免费试用版。
如果 Linux 上的Microsoft Defender for Endpoint出现问题,并且需要支持,系统可能会要求你提供客户端分析器工具的输出。 本文介绍如何在设备上或实时响应中使用该工具。 可以使用基于 Python 的解决方案或不需要 Python 的二进制版本。
运行客户端分析器的二进制版本
将 XMDE 客户端分析器二进制 工具下载到要调查的 Linux 计算机。 如果使用的是终端,请通过输入以下命令下载该工具:
wget --quiet -O XMDEClientAnalyzerBinary.zip https://aka.ms/XMDEClientAnalyzerBinary
验证下载。
echo 'B5EBD9AB36F2DB92C341ABEBB20A50551D08D769CB061EAFCC1A931EFACE305D XMDEClientAnalyzerBinary.zip' | sha256sum -c
在计算机上提取 的内容
XMDEClientAnalyzerBinary.zip
。unzip -q XMDEClientAnalyzerBinary.zip -d XMDEClientAnalyzerBinary
更改目录:
cd XMDEClientAnalyzerBinary
将生成两个新的 zip 文件:
- SupportToolLinuxBinary.zip:适用于所有 Linux 设备
- SupportToolMacOSBinary.zip:适用于 Mac 设备
SupportToolLinuxBinary.zip
解压缩文件。unzip -q SupportToolLinuxBinary.zip
以 root 身份运行该工具以生成诊断包:
sudo ./MDESupportTool -d
运行基于 Python 的客户端分析器
注意
- 分析器依赖于一些额外的 PIP 包,
decorator
(、sh
、distro
lxml
、 和psutil
) 这些包在根目录中安装,以生成结果输出。 如果未安装,分析器会尝试从 Python 包的官方存储库中提取它。 - 此外,该工具当前需要在设备上安装 Python 版本 3 或更高版本。
- 如果设备位于代理后面,则可以将代理服务器作为环境变量传递给
mde_support_tool.sh
脚本。 例如:https_proxy=https://myproxy.contoso.com:8080 ./mde_support_tool.sh"
。
警告
运行基于 Python 的客户端分析器需要安装 PIP 包,这可能会导致环境中的一些问题。 为了避免出现问题,建议将包安装到用户 PIP 环境中。
在需要调查的 Linux 计算机上下载 XMDE 客户端分析器 工具。 如果使用的是终端,请通过输入以下命令下载该工具:
wget --quiet -O XMDEClientAnalyzer.zip https://aka.ms/XMDEClientAnalyzer
验证下载。
echo '07E6A7B89E28A78309D5B6F1E25E4CDFBA9CA141450E422D76441C03AD3477E7 XMDEClientAnalyzer.zip' | sha256sum -c
在计算机上提取 的内容
XMDEClientAnalyzer.zip
。unzip -q XMDEClientAnalyzer.zip -d XMDEClientAnalyzer
更改目录。
cd XMDEClientAnalyzer
为工具授予可执行权限。
chmod a+x mde_support_tool.sh
以非根用户身份运行以安装所需的依赖项。
./mde_support_tool.sh
若要收集诊断包并生成结果存档文件,请再次以 root 身份运行。
sudo ./mde_support_tool.sh -d
命令行选项
下面是客户端分析器提供的命令行选项
usage: MDESupportTool [-h] [--output OUTPUT] [--outdir OUTDIR] [--no-zip]
[--force] [--diagnostic] [--skip-mdatp]
[--bypass-disclaimer] [--interactive] [--delay DELAY]
[--mdatp-log {trace,info,warning,error,debug,verbose}]
[--max-log-size MAX_LOG_SIZE]
{certinfocollection,performance,installation,exclude,ratelimit,skipfaultyrules,trace,observespikes,connectivitytest}
...
MDE Diagnostics Tool
positional arguments:
{certinfocollection,performance,installation,exclude,ratelimit,skipfaultyrules,trace,observespikes,connectivitytest}
certinfocollection Collect cert information: Subject name and Hashes
performance Collect extensive machine performance tracing for
analysis of a performance scenario that can be
reproduced on demand
installation Collect different installation/onboarding reports
exclude Exclude specific processes from audit-d monitoring.
ratelimit Set the rate limit for auditd events. Rate limit will
update the limits for auditd events for all the
applications using auditd, which could impact
applications other than MDE.
skipfaultyrules Continue loading rules in spite of an error. This
summarizes the results of loading the rules. The exit
code will not be success if any rule fails to load.
trace Use OS tracing facilities to record Defender
performance traces.
observespikes Collect the process logs in case of spike or mdatp
crash
connectivitytest Perform connectivity test for MDE
optional arguments:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Output path to export report
--outdir OUTDIR Directory where diagnostics file will be generated.
--no-zip, -nz If set a directory will be created instead of an
archive file.
--force, -f Will overwrite if output directory exists.
--diagnostic, -d Collect extensive machine diagnostic information.
--skip-mdatp Skip any mdatp command. Use this when the mdatp
command is unresponsive.
--bypass-disclaimer Do not display disclaimer banner.
--interactive, -i Interactive diagnostic,
--delay DELAY, -dd DELAY
Delay diagnostic by how many minutes (0~2880), use
this to wait for more debug logs before it collects.
--mdatp-log {trace,info,warning,error,debug,verbose}
Set MDATP log level. If you use interactive or delay
mode, the log level will set to debug automatically,
and reset after 48h.
--max-log-size MAX_LOG_SIZE
Maximum log file size in MB before rotating(Will
restart mdatp).
诊断模式
诊断模式用于收集大量计算机信息,例如内存、磁盘和 MDATP 日志。 这组文件提供了调试与 Defender For Endpoint 相关的任何问题所需的主要信息集。
支持的选项如下所示:
optional arguments:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Output path to export report
--outdir OUTDIR Directory where diagnostics file will be generated.
--no-zip, -nz If set a directory will be created instead of an
archive file.
--force, -f Will overwrite if output directory exists.
--diagnostic, -d Collect extensive machine diagnostic information.
--skip-mdatp Skip any mdatp command. Use this when the mdatp
command is unresponsive.
--bypass-disclaimer Do not display disclaimer banner.
--interactive, -i Interactive diagnostic,
--delay DELAY, -dd DELAY
Delay diagnostic by how many minutes (0~2880), use
this to wait for more debug logs before it collects.
--mdatp-log {trace,info,warning,error,debug,verbose}
Set MDATP log level. If you use interactive or delay
mode, the log level will set to debug automatically,
and reset after 48h.
--max-log-size MAX_LOG_SIZE
Maximum log file size in MB before rotating(Will
restart mdatp).
用法示例: sudo ./MDESupportTool -d
注意
日志级别自动重置功能仅在代理版本 101.24052.0002 或更高版本中可用。
下表汇总了使用此模式时生成的文件:
文件 | 备注 |
---|---|
mde_diagnostic.zip |
Defender for Endpoint 日志和配置 |
health.txt |
Defender for Endpoint 的运行状况 (仅在安装 Defender for Endpoint) 时才显示 |
health_details_features.txt |
其他 Defender for Endpoint 功能的运行状况 (仅在安装 Defender for Endpoint) 时才显示 |
permissions.txt |
Defender for Endpoint 拥有/使用的文件夹的权限问题 (仅在安装 Defender for Endpoint) 时才显示 |
crashes |
Defender for Endpoint 生成的故障转储 |
process_information.txt |
运行工具时在计算机中运行的进程 |
proc_directory_info.txt |
Defender for Endpoint 进程的虚拟内存映射 (仅在安装 Defender for Endpoint) 时才显示 |
auditd_info.txt |
审核的运行状况、规则、日志 |
auditd_log_analysis.txt |
已审核的事件摘要 |
auditd_logs.zip |
审核的日志文件 |
ebpf_kernel_config.txt |
当前加载的 Linux 内核配置 |
ebpf_enabled_func.txt |
当前启用跟踪的所有内核函数的列表 |
ebpf_syscalls.zip |
有关系统调用跟踪的信息 |
ebpf_raw_syscalls.zip |
跟踪与原始系统调用相关的事件 |
ebpf_maps_info.txt |
eBPF 地图的 ID 和大小信息 |
syslog.zip |
/var/log/syslog 下的文件 |
messages.zip |
/var/log/messages 下的文件 |
conflicting_processes_information.txt |
Defender for Endpoint 冲突进程 |
exclusions.txt |
防病毒排除项列表 |
definitions.txt |
防病毒定义信息 |
mde_directories.txt |
Defender for Endpoint 目录中的文件列表 |
disk_usage.txt |
磁盘使用情况详细信息 |
mde_user.txt |
Defender for Endpoint 用户信息 |
mde_definitions_mount.txt |
Defender for Endpoint 定义装入点 |
service_status.txt |
Defender for Endpoint 服务状态 |
service_file.txt |
Defender for Endpoint 服务文件 |
hardware_info.txt |
硬件信息 |
mount.txt |
装入点信息 |
uname.txt |
内核信息 |
memory.txt |
系统内存信息 |
meminfo.txt |
有关系统内存使用情况的详细信息 |
cpuinfo.txt |
CPU 信息 |
lsns_info.txt |
Linux 命名空间信息 |
lsof.txt |
Defender for Endpoint Open File 描述符信息 (此表) 后看到注释 |
sestatus.txt |
Defender for Endpoint Open File 描述符信息 |
lsmod.txt |
Linux 内核中模块的状态 |
dmesg.txt |
来自内核环形缓冲区的消息 |
kernel_lockdown.txt |
内核锁定信息 |
rtp_statistics.txt |
Defender for Endpoint 实时保护 (RTP) 统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
libc_info.txt |
libc 库信息 |
uptime_info.txt |
自上次重启以来的时间 |
last_info.txt |
上次登录用户的列表 |
locale_info.txt |
显示当前区域设置 |
tmp_files_owned_by_mdatp.txt |
组拥有的 /tmp 文件: mdatp (仅在安装 Defender for Endpoint) 时才显示 |
mdatp_config.txt |
所有 Defender for Endpoint 配置 (仅在安装 Defender for Endpoint) 时才显示 |
mpenginedb.db mpenginedb.db-wal mpenginedb.db-shm |
防病毒定义文件 (仅在安装 Defender for Endpoint) 时才显示 |
iptables_rules.txt |
Linux iptables 规则 |
network_info.txt |
网络信息 |
sysctl_info.txt |
内核设置信息 |
hostname_diagnostics.txt |
主机名诊断信息 |
mde_event_statistics.txt |
Defender for Endpoint 事件统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
mde_ebpf_statistics.txt |
Defender for Endpoint eBPF 统计信息 (仅在安装 Defender for Endpoint) 时才显示 |
kernel_logs.zip |
内核日志 |
mdc_log.zip |
云日志Microsoft Defender |
netext_config.txt |
|
threat_list.txt |
Defender for Endpoint 检测到的威胁列表 (仅在安装 Defender for Endpoint) 时才显示 |
top_output.txt |
运行工具时在计算机中运行的进程 |
top_summary.txt |
运行进程的内存和 CPU 使用率分析 |
客户端分析器的可选参数
客户端分析器为额外的数据收集提供了以下可选参数:
收集性能信息
收集 Defender for Endpoint 进程的广泛计算机性能跟踪,以分析可按需重现的性能方案。
-h, --help show this help message and exit
--frequency FREQUENCY
profile at this frequency
--length LENGTH length of time to collect (in seconds)
用法示例: sudo ./MDESupportTool performance --frequency 500
下面是使用此模式时生成的文件:
文件 | 备注 |
---|---|
perf_benchmark.tar.gz |
Defender for Endpoint 处理性能数据 |
注意
还会生成与诊断模式对应的文件。
tar 包含格式 <pid of a MDE process>.data
为 的文件。
可以使用 命令读取数据文件:
perf report -i <pid>.data
运行连接测试
此模式测试 Defender for Endpoint 所需的云资源是否可访问。
-h, --help show this help message and exit
-o ONBOARDING_SCRIPT, --onboarding-script ONBOARDING_SCRIPT
Path to onboarding script
-g GEO, --geo GEO Geo string to test <US|UK|EU|AU|CH|IN>
用法示例:
sudo ./MDESupportTool connectivitytest -o ~/MicrosoftDefenderATPOnboardingLinuxServer.py`
屏幕上打印的输出显示 URL 是否可访问。
收集不同的安装/载入报告
此模式收集与安装相关的信息,例如发行版和系统要求。
-h, --help show this help message and exit
-d, --distro Check for distro support
-m, --min-requirement Check for the system info against offical minimum requirements
-e, --external-dep Check for externel package dependency
-c, --connectivity Check for connectivity for services used by MDE
-a, --all Run all checks
-o ONBOARDING_SCRIPT, --onboarding-script ONBOARDING_SCRIPT
Path to onboarding script
-g GEO, --geo GEO Geo string to test <US|UK|EU|AU|CH|IN>
用法示例:
sudo ./MDESupportTool installation --all
生成单个报表 installation_report.json
。 文件中的键如下所示:
键 | 备注 |
---|---|
agent_version | 已安装的 Defender for Endpoint 版本 |
onboarding_status | 载入和响铃信息 |
support_status | 当前系统配置支持MDE |
发行版 | 安装代理的发行版是否受支持 |
connectivitytest | 连接测试层 |
min_requirement | 满足 CPU 和内存的最低要求 |
external_depedency | 是否满足外部依赖项 |
mde_health | MDE 代理的运行状况 |
folder_perm | 是否满足所需的文件夹权限 |
排除模式
此模式添加了用于监视的 audit-d
排除项。
-h, --help show this help message and exit
-e <executable>, --exe <executable>
exclude by executable name, i.e: bash
-p <process id>, --pid <process id>
exclude by process id, i.e: 911
-d <directory>, --dir <directory>
exclude by target path, i.e: /var/foo/bar
-x <executable> <directory>, --exe_dir <executable> <directory>
exclude by executable path and target path, i.e: /bin/bash /var/foo/bar
-q <q_size>, --queue <q_size>
set dispatcher q_depth size
-r, --remove remove exclusion file
-s, --stat get statistics about common executables
-l, --list list auditd rules
-o, --override Override the existing auditd exclusion rules file for mdatp
-c <syscall number>, --syscall <syscall number>
exclude all process of the given syscall
用法示例:
sudo ./MDESupportTool exclude -d /var/foo/bar`
AuditD 速率限制器
此选项全局设置 AuditD 的速率限制,导致所有审核事件下降。 启用限制器后,审核的事件限制为 2500 个事件/秒。在从 AuditD 端看到 CPU 使用率过高的情况下,可以使用此选项。
-h, --help show this help message and exit
-e <true/false>, --enable <true/false> enable/disable the rate limit with default values
用法示例:
sudo ./mde_support_tool.sh ratelimit -e true
注意
应谨慎使用此功能,因为它限制了整个审核子系统报告的事件数。 这也可以减少其他订阅者的事件数。
AuditD 跳过错误规则
使用此选项,可以在加载时跳过在审核规则文件中添加的错误规则。 它允许审核的子系统继续加载规则,即使存在错误的规则。
-h, --help show this help message and exit
-e <true/false>, --enable <true/false> enable/disable the option to skip the faulty rules. In case no argumanet is passed, the option will be true by default.
用法示例:
sudo ./mde_support_tool.sh skipfaultyrules -e true
注意
此功能会跳过错误规则。 必须进一步识别和修复错误规则。
使用 Defender for Endpoint 中的实时响应收集支持日志
XMDE 客户端分析器工具可以作为 二进制 包或 Python 包下载,可在 Linux 计算机上提取和执行。 这两个版本的 XMDE 客户端分析器都可以在实时响应会话期间执行。
- 对于安装,
unzip
需要包。 - 若要执行,
acl
需要包。
重要
窗口使用回车符和换行不可见字符来表示文件中一行的结束和新行的开头,但 Linux 系统仅使用文件行末尾的换行不可见字符。 在使用以下脚本时,如果在 Windows 上执行此作,此差异可能会导致脚本运行错误和失败。 一个潜在的解决方案是利用 适用于 Linux 的 Windows 子系统 和 dos2unix
包重新格式化脚本,使其与 Unix 和 Linux 格式标准保持一致。
安装 XMDE 客户端分析器
下载并提取 XMDE 客户端分析器。 可以使用二进制或 Python 版本,如下所示:
由于实时响应中可用的命令有限,因此必须在 bash 脚本中执行详细步骤。 通过拆分这些命令的安装和执行部分,可以运行一次安装脚本,并多次运行执行脚本。
重要
示例脚本假定计算机具有直接 Internet 访问权限,并且可以从Microsoft检索 XMDE 客户端分析器。 如果计算机没有直接 Internet 访问权限,则必须更新安装脚本,以便从计算机可以成功访问的位置提取 XMDE 客户端分析器。
二进制客户端分析器安装脚本
以下脚本执行 客户端分析器运行二进制版本的前六个步骤。 完成后,可从 目录中获取 /tmp/XMDEClientAnalyzerBinary/ClientAnalyzer
XMDE 客户端分析器二进制文件。
创建 bash 文件
InstallXMDEClientAnalyzer.sh
并将以下内容粘贴到其中。#! /usr/bin/bash echo "Starting Client Analyzer Script. Running As:" whoami echo "Getting XMDEClientAnalyzerBinary" wget --quiet -O /tmp/XMDEClientAnalyzerBinary.zip https://aka.ms/XMDEClientAnalyzerBinary echo '4E96E75B16244BB25BDBF34CBB3EB596BC2E9CE368BC4E532E8AE12DF2A1E19D /tmp/XMDEClientAnalyzerBinary.zip' | sha256sum -c echo "Unzipping XMDEClientAnalyzerBinary.zip" unzip -q /tmp/XMDEClientAnalyzerBinary.zip -d /tmp/XMDEClientAnalyzerBinary echo "Unzipping SupportToolLinuxBinary.zip" unzip -q /tmp/XMDEClientAnalyzerBinary/SupportToolLinuxBinary.zip -d /tmp/XMDEClientAnalyzerBinary/ClientAnalyzer echo "MDESupportTool installed at /tmp/XMDEClientAnalyzerBinary/ClientAnalyzer"
Python 客户端分析器安装脚本
以下脚本执行 运行 Python 版本的客户端分析器的前六个步骤。 完成后,可从 目录中获取 /tmp/XMDEClientAnalyzer
XMDE 客户端分析器 Python 脚本。
创建 bash 文件
InstallXMDEClientAnalyzer.sh
并将以下内容粘贴到其中。#! /usr/bin/bash echo "Starting Client Analyzer Install Script. Running As:" whoami echo "Getting XMDEClientAnalyzer.zip" wget --quiet -O /tmp/XMDEClientAnalyzer.zip https://aka.ms/XMDEClientAnalyzer echo '07E6A7B89E28A78309D5B6F1E25E4CDFBA9CA141450E422D76441C03AD3477E7 /tmp/XMDEClientAnalyzer.zip' | sha256sum -c echo "Unzipping XMDEClientAnalyzer.zip" unzip -q /tmp/XMDEClientAnalyzer.zip -d /tmp/XMDEClientAnalyzer echo "Setting execute permissions on mde_support_tool.sh script" cd /tmp/XMDEClientAnalyzer chmod a+x mde_support_tool.sh echo "Performing final support tool setup" ./mde_support_tool.sh
运行客户端分析器安装脚本
在要调查的计算机上启动 实时响应会话 。
选择“ 将文件上传到库”。
选择“ 选择文件”。
选择名为
InstallXMDEClientAnalyzer.sh
的下载文件,然后选择“ 确认”。仍在 LiveResponse 会话中时,使用以下命令安装分析器:
run InstallXMDEClientAnalyzer.sh
运行 XMDE 客户端分析器
实时响应不支持直接运行 XMDE 客户端分析器或 Python,因此需要执行脚本。
重要
以下脚本假定使用前面提到的脚本中的相同位置安装了 XMDE 客户端分析器。 如果组织选择将脚本安装到其他位置,则必须更新脚本以与组织选择的安装位置保持一致。
用于执行二进制客户端分析器的脚本
客户端分析器的二进制版本接受命令行参数来执行不同的分析测试。 为了在实时响应期间提供类似的功能,执行脚本利用 $@
bash 变量将提供给脚本的所有输入参数传递给 XMDE 客户端分析器。
创建 bash 文件
MDESupportTool.sh
并将以下内容粘贴到其中。#! /usr/bin/bash echo "cd /tmp/XMDEClientAnalyzerBinary/ClientAnalyzer" cd /tmp/XMDEClientAnalyzerBinary/ClientAnalyzer echo "Running MDESupportTool" ./MDESupportTool $@
用于执行 Python 客户端分析器的脚本
客户端分析器的 Python 版本接受命令行参数来执行不同的分析测试。 为了在实时响应期间提供类似的功能,执行脚本利用 $@
bash 变量将提供给脚本的所有输入参数传递给 XMDE 客户端分析器。
创建 bash 文件
MDESupportTool.sh
并将以下内容粘贴到其中。#! /usr/bin/bash echo "cd /tmp/XMDEClientAnalyzer" cd /tmp/XMDEClientAnalyzer echo "Running mde_support_tool" ./mde_support_tool.sh $@
运行客户端分析器脚本
注意
如果你有活动的实时响应会话,则可以跳过步骤 1。
在要调查的计算机上启动 实时响应会话 。
选择“ 将文件上传到库”。
选择“ 选择文件”。
选择名为
MDESupportTool.sh
的下载文件,然后选择“ 确认”。仍处于实时响应会话中时,请使用以下命令运行分析器并收集生成的文件:
run MDESupportTool.sh -parameters "--bypass-disclaimer -d" GetFile "/tmp/your_archive_file_name_here.zip"
另请参阅
Linux 上的 Defender for Endpoint 故障排除文档
提示
想要了解更多信息? Engage技术社区中的Microsoft安全社区:Microsoft Defender for Endpoint技术社区。