排查命令速查
前置说明
本页面覆盖 Windows 应急响应中最常用的排查命令,从 CMD 到 PowerShell 到 WMIC
对于有 Linux IR 经验的工程师,文末附有 Linux应急响应/命令对照表 方便快速对应
所有命令均在 Windows Server 2016/2019/2022 和 Windows 10/11 上验证
建议以 管理员权限 打开 CMD 或 PowerShell,否则部分命令输出不完整
关联页面:Windows应急响应/01-基础知识 | 03-事件日志分析 | Windows应急响应/04-持久化排查
一、CMD 命令(传统但依然重要) 虽然 PowerShell 已成为主流,但 CMD 命令在以下场景仍不可替代:
目标机器 PowerShell 被限制执行策略(Constrained Language Mode)
远程通过 PsExec 执行命令(CMD 兼容性最好)
老旧系统(Server 2008/2003)只有 CMD 可用
快速一行命令排查,不需要 PS 的复杂对象管道
1.1 进程排查 tasklist /v /fo csv — 详细进程列表(CSV 格式)
用途:列出所有进程,含用户名、CPU 时间、窗口标题,CSV 格式便于导出分析
关键参数:/v 详细模式,/fo csv CSV 格式输出,/fi 过滤条件
Linux 对应:ps aux 或 ps -ef
1 2 3 4 5 6 7 8 C:\> tasklist /v /fo csv > C :\IR \processlist.csv # 输出示例(部分): "Image Name ","PID ","Session Name ","Session #","Mem Usage ","Status ","User Name ","CPU Time ","Window Title " "System Idle Process ","0","Services ","0","8 K ","Unknown ","NT AUTHORITY \SYSTEM ","168:32:14","N /A " "svchost.exe ","1024","Services ","0","22,456 K ","Running ","NT AUTHORITY \SYSTEM ","0:05:32","N /A " "powershell.exe ","6688","Console ","1","98,432 K ","Running ","CORP \admin ","0:00:15","Windows PowerShell " "svchost.exe ","8844","Console ","1","45,120 K ","Running ","CORP \admin ","2:34:56","N /A "
异常指标:
进程名拼写与系统进程相似但不同:svchost.exe(正确应为 svchost.exe)
非 SYSTEM 账户运行的 svchost.exe
CPU Time 异常高的未知进程(可能是挖矿)
用户进程在 Services session 中运行
tasklist /svc — 进程与服务映射
用途:显示每个进程承载的服务,快速定位可疑 svchost.exe 实例
Linux 对应:systemctl status 或 ps -ef | grep <service>
1 2 3 4 5 6 7 8 C:\> tasklist /svc Image Name PID Services ========================= ======== ============================================ svchost.exe 1024 DcomLaunch , PlugPlay , Power svchost.exe 1200 RpcEptMapper , RpcSs svchost.exe 3456 LanmanServer svchost.exe 8888 MyUpdateSvc
异常指标:
svchost.exe 只承载一个陌生服务名(如 MyUpdateSvc)
服务名不在已知 Windows 服务列表中
tasklist /m — 进程加载的 DLL 模块
用途:查看进程加载了哪些 DLL,检测 DLL 注入或劫持
Linux 对应:lsof -p <pid> 或 cat /proc/<pid>/maps
1 2 3 4 5 6 C:\> tasklist /m /fi "PID eq 8844" Image Name PID Modules ========================= ======== ============================================ svchost.exe 8844 ntdll.dll , kernel32.dll , KERNELBASE.dll , ws2_32.dll , mswsock.dll , evil.dll
异常指标:
非标准路径的 DLL(正常 DLL 在 C:\Windows\System32\)
名称可疑的 DLL:evil.dll、update.dll(在非常规目录)
加载了 ws2_32.dll(网络库)的非网络程序
tasklist /fi — 条件过滤
1 2 3 4 5 6 7 8 # 查找特定用户的进程 C:\> tasklist /fi "USERNAME eq CORP \admin " /v # 查找内存占用超过 100MB 的进程 C :\> tasklist /fi "MEMUSAGE gt 100000" /v # 查找特定状态 C :\> tasklist /fi "STATUS eq running " /v
1.2 网络排查 netstat -ano — 网络连接与进程关联
用途:显示所有网络连接、监听端口及对应 PID,Windows IR 最常用网络命令
关键参数:-a 所有连接,-n 数字格式,-o 显示 PID,-b 显示进程名(需管理员)
Linux 对应:ss -tulnp 或 netstat -tulnp
1 2 3 4 5 6 7 8 9 10 11 12 C:\> netstat -ano Active Connections Proto Local Address Foreign Address State PID TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1024 TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1200 TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING 4 TCP 10.0.1.50:49732 185.234.72.14:443 ESTABLISHED 8844 TCP 10.0.1.50:49801 10.0.1.100:445 ESTABLISHED 4 TCP 10.0.1.50:52300 91.215.85.29:4444 ESTABLISHED 6688 UDP 0.0.0.0:5353 *:* 2100
异常指标:
连接到非常见端口的外部 IP(如 4444、8080、1234 — 常见 C2 端口)
连接到已知恶意 IP 段(如东欧、特定 VPS 提供商 IP)
大量 ESTABLISHED 到同一内网 IP 的 445 端口(横向移动)
非浏览器进程的 443 外连
LISTENING 在非标准端口
netstat -anob — 带进程名的网络连接(需管理员)
1 2 3 4 5 6 7 8 C:\> netstat -anob Active Connections Proto Local Address Foreign Address State PID TCP 10.0.1.50:49732 185.234.72.14:443 ESTABLISHED 8844 [svchost.exe ] TCP 10.0.1.50:52300 91.215.85.29:4444 ESTABLISHED 6688 [powershell.exe ]
异常指标:
powershell.exe 直接外连(正常 PS 脚本很少直连外部 IP)
伪装系统进程名有外连行为
ipconfig /all — 网络适配器完整信息
用途:获取 IP、DNS、DHCP、MAC 地址等完整网络配置
Linux 对应:ip addr + cat /etc/resolv.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 C:\> ipconfig /all Windows IP Configuration Host Name . . . . . . . . : WEB -SVR01 Primary Dns Suffix . . . : corp.example.com DNS Suffix Search List . . : corp.example.com Ethernet adapter Ethernet0 : IPv4 Address . . . . . . . : 10.0.1.50 Subnet Mask . . . . . . . : 255.255.255.0 Default Gateway . . . . . : 10.0.1.1 DNS Servers . . . . . . . : 10.0.1.10 10.0.1.11 DHCP Enabled . . . . . . . : No
异常指标:
DNS 服务器被改为外部地址(DNS 劫持)
出现未知的虚拟网卡(可能是 VPN 隧道或攻击者工具)
DHCP 在服务器上被启用(服务器通常用静态 IP)
ipconfig /displaydns — DNS 缓存查看
用途:查看本地 DNS 解析缓存,发现恶意域名解析记录
Linux 对应:Linux 默认无系统级 DNS 缓存(除非装了 systemd-resolved,用 resolvectl statistics)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 C:\> ipconfig /displaydns Windows IP Configuration update -service.kfroc.xyz ---------------------------------------- Record Name . . . . . : update -service.kfroc.xyz Record Type . . . . . : 1 Time To Live . . . . : 120 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host ) Record . . . : 185.234.72.14 www.microsoft.com ---------------------------------------- Record Name . . . . . : www.microsoft.com Record Type . . . . . : 5 ...
异常指标:
随机子域名(DGA 域名特征):a3f8kd.evil.com
已知恶意域名或 C2 域名
大量不同子域名指向同一 IP(DNS 隧道特征)
arp -a — ARP 缓存表
用途:查看 IP-MAC 映射,检测 ARP 欺骗
Linux 对应:arp -n 或 ip neigh
1 2 3 4 5 6 7 C:\> arp -a Interface : 10.0.1.50 --- 0x3 Internet Address Physical Address Type 10.0.1.1 00-50-56-fe -00-01 dynamic 10.0.1.100 00-50-56-fe -00-02 dynamic 10.0.1.200 00-50-56-fe -00-01 dynamic
异常指标:
两个不同 IP 对应相同 MAC 地址(ARP 欺骗/中间人攻击)
网关 MAC 地址变化
route print — 路由表
用途:查看路由配置,检测是否被添加异常路由规则
Linux 对应:ip route 或 route -n
1 2 3 4 5 6 7 8 9 C:\> route print IPv4 Route Table =========================================================================== Active Routes :Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 10.0.1.1 10.0.1.50 10 10.0.1.0 255.255.255.0 On -link 10.0.1.50 266 172.16.0.0 255.255.0.0 10.0.1.254 10.0.1.50 20
异常指标:
指向未知网关的路由条目
不属于企业网段的静态路由
nbtstat -n — NetBIOS 名称表
用途:查看本机 NetBIOS 注册名称,检测名称欺骗
Linux 对应:nmblookup 或 smbclient -L
1 2 3 4 5 6 7 8 9 10 C:\> nbtstat -n Local Area Connection :Node IpAddress : [10.0.1.50] Scope Id : [] NetBIOS Local Name Table Name Type Status --------------------------------------------- WEB -SVR01 <00> UNIQUE Registered CORP <00> GROUP Registered WEB -SVR01 <20> UNIQUE Registered
1.3 用户与会话排查 net user — 本地用户列表
用途:列出所有本地用户账户
Linux 对应:cat /etc/passwd 或 getent passwd
1 2 3 4 5 6 7 C:\> net user User accounts for \\WEB -SVR01 ------------------------------------------------------------------------------- Administrator DefaultAccount Guest support $ svc_backup WDAGUtilityAccount The command completed successfully .
异常指标:
以 $ 结尾的用户名(隐藏用户,如 support$)— Windows 特有技巧
不在运维人员清单内的用户
命名模式不符合企业规范的账户
net user <username> — 用户详细信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 C:\> net user support $ User name support $Full Name Comment User 's comment Country /region code 000 (System Default )Account active Yes Account expires Never Password last set 3/15/2026 02:30:14 AM Password expires Never Password changeable 3/15/2026 02:30:14 AM Password required Yes User may change password Yes Workstations allowed All Logon script User profile Home directory Last logon 4/1/2026 08:45:22 PM Logon hours allowed All Local Group Memberships *Administrators *Remote Desktop Users Global Group memberships *None The command completed successfully .
异常指标:
凌晨创建的账户(Password last set 在非工作时间)
密码永不过期
属于 Administrators 和 Remote Desktop Users 组
Last logon 时间异常(深夜或节假日)
net localgroup Administrators — 管理员组成员
用途:列出本地管理员组所有成员,检测越权提升
Linux 对应:getent group sudo 或 grep wheel /etc/group
1 2 3 4 5 6 7 8 9 10 11 C:\> net localgroup Administrators Alias name Administrators Comment Administrators have complete and unrestricted access Members ------------------------------------------------------------------------------- Administrator CORP \Domain Admins CORP \IT -Ops support $The command completed successfully .
异常指标:
非预期的本地账户在管理员组中
隐藏用户($ 结尾)在管理员组
net session — 当前入站会话
用途:查看谁正在通过网络连接到本机(SMB 会话)
Linux 对应:smbstatus 或 ss -tnp | grep 445
1 2 3 4 5 6 C:\> net session Computer User name Client Type Opens Idle time ------------------------------------------------------------------------------- \\10.0.1.200 CORP \attacker Windows 10 3 00:00:05 \\10.0.1.100 CORP \svc_backup Windows Server 1 00:15:20
net use — 出站网络映射
用途:查看本机到外部的网络驱动器映射 / 共享连接
Linux 对应:mount | grep cifs 或 smbclient
1 2 3 4 5 6 7 C:\> net use New connections will be remembered .Status Local Remote Network ------------------------------------------------------------------------------- OK Z : \\10.0.1.100\C $ Microsoft Windows Network OK \\DC01 \SYSVOL Microsoft Windows Network
异常指标:
映射到其他机器的 C$(管理共享)— 横向移动标志
映射到非企业资产的共享路径
query user / qwinsta — 登录会话
用途:查看当前登录的用户会话,包括 RDP 会话
Linux 对应:w 或 who
1 2 3 4 5 6 7 8 9 10 11 C:\> query user USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME administrator console 1 Active none 3/28/2026 9:00 AM support $ rdp -tcp #5 3 Active . 4/1/2026 8:30 PM C :\> qwinsta SESSIONNAME USERNAME ID STATE TYPE DEVICE services 0 Disc console administrator 1 Active rdp -tcp #5 support $ 3 Active rdp -tcp 65536 Listen
异常指标:
非工作时间的 RDP 活动会话
可疑账户的远程桌面会话
多个并发 RDP 会话(正常服务器通常只有 1-2 个管理会话)
1.4 文件排查 dir /a /s /t:c — 递归文件列表(按创建时间)
用途:递归列出目录下所有文件(含隐藏/系统文件),显示创建时间
关键参数:/a 含隐藏和系统文件,/s 递归子目录,/t:c 按创建时间,/t:w 按修改时间
Linux 对应:find / -type f -ls 或 ls -laR
1 2 3 4 5 6 7 8 # 查看 Temp 目录下最近创建的文件 C:\> dir /a /s /t:c C :\Windows \Temp \ # 查看指定时间范围的文件(借助 forfiles ) C :\> forfiles /P C :\ /S /D +03/28/2026 /C "cmd /c echo @path @fdate @ftime "# 查找特定后缀 C :\> dir /a /s /t:c C :\Users \*.exe C :\Users \*.dll C :\Users \*.ps1 C :\Users \*.bat
异常指标:
C:\Windows\Temp\ 下的 .exe、.dll、.ps1 文件
C:\Users\Public\ 下的可执行文件
创建时间在入侵时间窗口内的文件
attrib — 文件属性查看
用途:查看文件的隐藏(H)、系统(S)、只读(R)、存档(A)属性
Linux 对应:lsattr(ext 文件系统属性)
1 2 3 4 C:\> attrib C :\Windows \Temp \* A SH C :\Windows \Temp \svchost.exe A C :\Windows \Temp \debug.log
异常指标:
可执行文件被设置为隐藏+系统属性(SH)— 典型的恶意文件隐藏技巧
icacls — 文件权限查看
用途:查看文件/目录的 ACL 权限,检测权限异常
Linux 对应:getfacl 或 ls -la
1 2 3 4 5 C:\> icacls C :\Windows \Temp \svchost.exe C :\Windows \Temp \svchost.exe Everyone :(F ) BUILTIN \Users :(F ) Successfully processed 1 files ; Failed processing 0 files
异常指标:
Everyone:(F) 完全控制 — 正常系统文件不会这样设置
可执行文件权限被过度放开
cipher /u — EFS 加密文件查找
用途:查找系统中使用 EFS 加密的文件,勒索软件有时使用 EFS
1.5 服务排查 sc query — 服务状态查询
用途:列出所有服务及其运行状态
Linux 对应:systemctl list-units --type=service
1 2 3 4 5 6 7 C:\> sc query type = service state = all SERVICE_NAME : MyUpdateSvc DISPLAY_NAME : My Update Service TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING WIN32_EXIT_CODE : 0 (0x0 )
sc qc <name> — 服务详细配置
用途:查看服务的二进制路径、启动类型、运行账户
Linux 对应:systemctl cat <service>
1 2 3 4 5 6 7 8 9 10 11 12 13 C:\> sc qc MyUpdateSvc [SC ] QueryServiceConfig SUCCESS SERVICE_NAME : MyUpdateSvc TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 2 AUTO_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : C :\ProgramData \Update \svc.exe -k netsvcs LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : My Update Service DEPENDENCIES : SERVICE_START_NAME : LocalSystem
异常指标:
BINARY_PATH_NAME 指向非标准路径(C:\ProgramData\、C:\Users\、C:\Temp\)
以 LocalSystem 运行的非系统服务
路径中含空格但无引号(Unquoted Service Path 漏洞)
START_TYPE 为 AUTO_START 的陌生服务
wmic service list brief — 服务概览
1 2 3 4 5 C:\> wmic service list brief ExitCode Name ProcessId StartMode State Status 0 MyUpdateSvc 8844 Auto Running OK 0 Spooler 2200 Auto Running OK
1.6 计划任务排查 schtasks /query /fo list /v — 计划任务完整列表
用途:列出所有计划任务的详细信息,含执行命令、触发条件、运行账户
Linux 对应:crontab -l + ls /etc/cron.* + systemctl list-timers
1 2 3 4 5 6 7 8 9 10 11 12 13 C:\> schtasks /query /fo list /v Folder : \Microsoft \Windows \UpdateCheck HostName : WEB -SVR01 TaskName : \Microsoft \Windows \UpdateCheck \SystemUpdate Next Run Time : 4/2/2026 3:00:00 AM Status : Ready Logon Mode : Interactive /Background Last Run Time : 4/1/2026 3:00:00 AM Last Result : 0Author : CORP \support $Task To Run : powershell.exe -nop -w hidden -enc SQBFAFgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQA ...Run As User : SYSTEM
异常指标:
Task To Run 含 powershell.exe -enc(Base64 编码命令)
任务路径模仿系统任务目录但名称不是 Windows 原生任务
Run As User 为 SYSTEM 但 Author 是普通用户
每隔很短时间(如 5 分钟)执行的任务
凌晨执行的可疑任务
1.7 系统信息 systeminfo — 系统概览
用途:获取操作系统版本、补丁列表、启动时间、硬件信息
Linux 对应:uname -a + cat /etc/os-release + uptime
1 2 3 4 5 6 7 8 9 10 11 C:\> systeminfo Host Name : WEB -SVR01 OS Name : Microsoft Windows Server 2019 Standard OS Version : 10.0.17763 N /A Build 17763System Boot Time : 3/1/2026, 10:00:00 AM System Manufacturer : VMware , Inc .Total Physical Memory : 8,192 MB Hotfix (s ): 15 Hotfix (s ) Installed . [01]: KB5035849 [02]: KB5034439
异常指标:
长时间未重启(攻击者不想丢失内存驻留的恶意代码)
补丁缺失严重(利用已知漏洞入侵的可能性高)
whoami /all — 当前用户完整信息
用途:查看当前用户的 SID、组成员、权限(Privileges)
Linux 对应:id + groups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 C:\> whoami /all USER INFORMATION ---------------- User Name SID =================== ============================================= corp \admin S -1-5-21-1234567890-1234567890-1234567890-1001PRIVILEGES INFORMATION ---------------------- Privilege Name Description State =============================== =============================== ======== SeDebugPrivilege Debug programs Enabled SeImpersonatePrivilege Impersonate a client Enabled SeBackupPrivilege Back up files and directories Enabled
异常指标:
SeDebugPrivilege Enabled — 可以注入任意进程
SeImpersonatePrivilege Enabled — Potato 系列提权的前提
set — 环境变量
用途:查看所有环境变量,检测 PATH 劫持等
Linux 对应:env 或 printenv
1 2 3 4 5 6 C:\> set COMPUTERNAME =WEB -SVR01 OS =Windows_NT PATH =C :\ProgramData \Update ;C :\Windows \system32 ;C :\Windows ;...TEMP =C :\Users \admin \AppData \Local \Temp
异常指标:
PATH 中包含可疑路径排在系统路径之前(PATH 劫持)
二、PowerShell 命令(现代 IR 核心) PowerShell 是 Windows IR 的核心工具,优势在于:
结构化对象输出(不是纯文本,可精确筛选和格式化)
丰富的 CIM/WMI 查询能力
远程执行(Invoke-Command -ComputerName)
强大的事件日志查询(Get-WinEvent)
对于习惯 Linux 管道(grep | awk | sed)的工程师,PS 的对象管道需要适应:
grep → Where-Object 或 Select-String
awk '{print $1}' → Select-Object Property
sort | uniq -c → Group-Object | Sort-Object Count
2.1 进程排查 Get-Process — 基础进程列表
1 2 3 4 5 6 7 8 9 Get-Process | Sort-Object CPU -Descending | Select-Object -First 20 Id, ProcessName, CPU, WorkingSet, Path
异常指标:
CPU 占用极高的未知进程(挖矿)
Path 不在 C:\Windows\ 或 C:\Program Files\ 下的可疑进程
Get-Process -IncludeUserName — 含用户名(需管理员)
1 2 3 4 5 6 7 8 Get-Process -IncludeUserName | Where-Object { $_ .UserName -notlike "NT AUTHORITY\*" -and $_ .UserName -notlike "NT SERVICE\*" } | Select-Object Id, ProcessName, UserName, Path | Format-Table -AutoSize
Get-CimInstance Win32_Process — 完整进程信息(含命令行和父进程)
用途:获取进程的完整命令行参数和父进程 ID,这是 Linux ps -ef 的完整对应
这是 Windows IR 中最重要的进程排查命令之一
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Get-CimInstance Win32_Process | Select-Object ProcessId, ParentProcessId, Name, CommandLine, CreationDate | Format-List
异常指标:
CommandLine 含 -enc(Base64)、-nop(NoProfile)、-w hidden(WindowStyle Hidden)
CommandLine 含 IEX、DownloadString、Invoke-Expression
父子进程关系异常:winword.exe → cmd.exe → powershell.exe(宏利用链)
svchost.exe 的父进程不是 services.exe(PID 通常很小)
实用技巧:构建进程树
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 function Get-ProcessTree { param ([int ]$ProcessId ) $proc = Get-CimInstance Win32_Process -Filter "ProcessId=$ProcessId " if ($proc ) { Write-Host "$ ($proc .ProcessId) - $ ($proc .Name) - $ ($proc .CommandLine)" if ($proc .ParentProcessId -ne 0 ) { Get-ProcessTree -ProcessId $proc .ParentProcessId } } } Get-ProcessTree -ProcessId 8844
这个进程链说明:IIS worker → PowerShell 下载执行 → 恶意进程,典型 Web 入侵路径
2.2 网络排查 Get-NetTCPConnection — TCP 连接(PowerShell 原生)
用途:替代 netstat,对象输出更易过滤,可直接关联进程信息
Linux 对应:ss -tnp
1 2 3 4 5 6 7 8 9 10 11 12 13 Get-NetTCPConnection -State Established | Where-Object { $_ .RemoteAddress -notlike "127.*" -and $_ .RemoteAddress -notlike "::1" } | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, OwningProcess, @ {N='ProcessName' ;E={(Get-Process -Id $_ .OwningProcess -ErrorAction SilentlyContinue).ProcessName}} | Format-Table -AutoSize
实用技巧:按远程 IP 聚合连接数
1 2 3 4 5 6 7 8 9 10 11 Get-NetTCPConnection -State Established | Group-Object RemoteAddress | Sort-Object Count -Descending | Select-Object Count, Name -First 10
Get-NetUDPEndpoint — UDP 端点
1 2 3 4 Get-NetUDPEndpoint | Select-Object LocalAddress, LocalPort, OwningProcess, @ {N='ProcessName' ;E={(Get-Process -Id $_ .OwningProcess -ErrorAction SilentlyContinue).ProcessName}} | Format-Table -AutoSize
Get-DnsClientCache — DNS 缓存(对象化)
1 2 3 4 5 6 7 8 9 10 Get-DnsClientCache | Where-Object { $_ .Type -eq 1 } | Select-Object Entry, Data | Sort-Object Entry
Resolve-DnsName — DNS 解析
1 2 3 4 5 Resolve-DnsName 185.234 .72.14 -Type PTRResolve-DnsName update-service .kfroc.xyz -Type A
2.3 用户与认证排查 Get-LocalUser — 本地用户完整信息
1 2 3 4 5 6 7 8 9 Get-LocalUser | Select-Object Name, Enabled, LastLogon, PasswordLastSet, PasswordExpires, Description | Format-Table -AutoSize
异常指标:
无 Description 的启用账户
PasswordExpires 为空(永不过期)
最近创建(PasswordLastSet 在入侵时间窗口)
Get-LocalGroupMember Administrators — 管理员组成员
1 2 3 4 5 6 7 8 Get-LocalGroupMember -Group "Administrators" | Select-Object Name, ObjectClass, PrincipalSource
Get-WinEvent 查询登录事件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Get-WinEvent -FilterHashtable @ { LogName='Security' ID=4624 StartTime=(Get-Date ).AddHours(-24 ) } | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { TimeCreated = $_ .TimeCreated LogonType = $xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'LogonType' } | Select-Object -ExpandProperty '#text' TargetUser = $xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetUserName' } | Select-Object -ExpandProperty '#text' SourceIP = $xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'IpAddress' } | Select-Object -ExpandProperty '#text' SourcePort = $xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'IpPort' } | Select-Object -ExpandProperty '#text' } } | Where-Object { $_ .LogonType -in @ ('2' ,'10' ,'11' ) } | Format-Table -AutoSize
异常指标:
LogonType 10(RDP)来自外部 IP
非工作时间的 Type 2(交互式)登录
详细分析见 03-事件日志分析
2.4 文件排查 Get-ChildItem -Recurse -Force — 递归文件列表
1 2 3 4 5 6 7 8 9 10 11 12 Get-ChildItem -Path C:\ -Recurse -Force -ErrorAction SilentlyContinue -Include *.exe,*.dll,*.ps1,*.bat,*.vbs,*.js | Where-Object { $_ .CreationTime -gt (Get-Date ).AddHours(-24 ) } | Select-Object FullName, CreationTime, Length, @ {N='Owner' ;E={(Get-Acl $_ .FullName).Owner}} | Sort-Object CreationTime -Descending
Get-FileHash — 文件哈希计算
用途:计算文件 MD5/SHA256 哈希,用于 IOC 比对和 VirusTotal 查询
Linux 对应:md5sum / sha256sum
1 2 3 4 5 6 7 8 9 10 11 12 Get-FileHash C:\ProgramData\Update\svc.exe -Algorithm SHA256Get-ChildItem C:\ProgramData\Update\, C:\Windows\Temp\, C:\Users\Public\ -Recurse -Force -ErrorAction SilentlyContinue -Include *.exe,*.dll | Get-FileHash -Algorithm SHA256 | Export-Csv C:\IR\hashes.csv -NoTypeInformation
Get-Item -Stream * — ADS 交换数据流检测
用途:检查 NTFS Alternate Data Streams,攻击者可在 ADS 中隐藏数据
Linux 无对应(NTFS 特有功能)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Get-Item C:\Windows\Temp\debug.log -Stream * | Where-Object { $_ .Stream -ne ':$DATA' }Get-Content C:\Windows\Temp\debug.log -Stream payload -Encoding Byte -ReadCount 0 | Set-Content C:\IR\extracted_payload.bin -Encoding ByteGet-ChildItem C:\Users\ -Recurse -Force -ErrorAction SilentlyContinue | Get-Item -Stream * -ErrorAction SilentlyContinue | Where-Object { $_ .Stream -ne ':$DATA' -and $_ .Stream -ne 'Zone.Identifier' }
说明: Zone.Identifier 是正常的 ADS(标记文件来源),其他非 $DATA 的流需要关注
Get-AuthenticodeSignature — 数字签名验证
用途:检查可执行文件的数字签名是否有效
Linux 对应:无直接对应(Linux 可用 codesign -v 在 macOS)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Get-AuthenticodeSignature C:\ProgramData\Update\svc.exeGet-ChildItem C:\Windows\System32\*.exe | Get-AuthenticodeSignature | Where-Object { $_ .Status -ne 'Valid' } | Select-Object Path, Status
2.5 服务排查 Get-Service — 服务列表
1 Get-Service | Where-Object { $_ .Status -eq 'Running' } | Sort-Object DisplayName
Get-WmiObject Win32_Service — 服务详细信息(含路径)
1 2 3 4 5 6 7 8 9 10 11 Get-WmiObject Win32_Service | Select-Object Name, StartMode, State, PathName, StartName | Where-Object { $_ .StartMode -eq 'Auto' -and $_ .State -eq 'Running' } | Format-Table -AutoSize -Wrap
实用:查找非标准路径的服务
1 2 3 4 5 6 7 8 Get-WmiObject Win32_Service | Where-Object { $_ .PathName -and $_ .PathName -notlike "*\Windows\*" -and $_ .PathName -notlike "*\Program Files*" -and $_ .State -eq 'Running' } | Select-Object Name, PathName, StartName
2.6 注册表排查 自启动项(Run Keys)
用途:检查注册表中的自启动项,这是最常见的持久化机制之一
Linux 对应:/etc/rc.local、~/.bashrc、systemd service 文件
1 2 3 4 5 6 7 8 9 10 11 12 13 Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -ErrorAction SilentlyContinueGet-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' -ErrorAction SilentlyContinueGet-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -ErrorAction SilentlyContinue
异常指标:
指向 C:\ProgramData\、C:\Users\Public\、%TEMP% 的条目
含 powershell -enc 的值
名称模仿系统组件但路径不对
全面自启动排查
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $paths = @ ( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' , 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' , 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' , 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' , 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices' , 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run' , 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run' , 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' , 'HKLM:\SYSTEM\CurrentControlSet\Services' ) foreach ($path in $paths ) { Write-Host "`n--- $path ---" -ForegroundColor Cyan Get-ItemProperty $path -ErrorAction SilentlyContinue }
Winlogon 持久化
1 2 3 4 5 6 7 8 9 10 Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' | Select-Object Shell, Userinit
2.7 日志查询 Get-WinEvent -FilterHashtable — 高效日志查询
详细用法见 03-事件日志分析 ,这里给出快速参考
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Get-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4625 ; StartTime=(Get-Date ).AddHours(-24 )} | Measure-Object | Select-Object Count Get-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4625 ; StartTime=(Get-Date ).AddHours(-24 )} | ForEach-Object { $xml = [xml ]$_ .ToXml() ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'IpAddress' }).'#text' } | Group-Object | Sort-Object Count -Descending | Select-Object Count, Name -First 10
Get-WinEvent -FilterXPath — XPath 精确查询
1 2 3 4 5 Get-WinEvent -LogName Security -FilterXPath "*[System[(EventID=4624)] and EventData[Data[@Name='LogonType']='10'] and EventData[Data[@Name='TargetUserName']='support$ ']]" -MaxEvents 10 Get-WinEvent -LogName Security -FilterXPath "*[System[(EventID=4624)] and EventData[Data[@Name='IpAddress']='91.215.85.29']]"
2.8 计划任务排查 Get-ScheduledTask — 计划任务列表
1 2 3 4 5 6 7 8 9 10 11 Get-ScheduledTask | Where-Object { $_ .State -eq 'Ready' -and $_ .Author -notlike 'Microsoft*' -and $_ .TaskPath -notlike '\Microsoft\*' } | Select-Object TaskName, TaskPath, Author, State | Format-Table -AutoSize
获取计划任务的执行命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Get-ScheduledTask | ForEach-Object { $info = $_ | Get-ScheduledTaskInfo -ErrorAction SilentlyContinue $actions = $_ .Actions [PSCustomObject ]@ { TaskName = $_ .TaskName TaskPath = $_ .TaskPath Author = $_ .Author Execute = $actions .Execute Arguments = $actions .Arguments LastRun = $info .LastRunTime NextRun = $info .NextRunTime RunAsUser = $_ .Principal.UserId } } | Where-Object { $_ .Execute } | Format-List
2.9 WMI 持久化排查 WMI Event Subscription — 高级持久化
用途:WMI 事件订阅是一种高级持久化技术,无文件落地、无注册表痕迹,排查难度高
Linux 无直接对应(类似 inotifywait + cron 的组合)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Get-WmiObject -Namespace root\Subscription -Class __EventFilterGet-WmiObject -Namespace root\Subscription -Class CommandLineEventConsumerGet-WmiObject -Namespace root\Subscription -Class ActiveScriptEventConsumerGet-WmiObject -Namespace root\Subscription -Class __FilterToConsumerBinding
说明: 正常系统 WMI 订阅应该为空或只有少量已知的安全软件订阅
三、WMIC 命令(遗留但常见) WMIC 在 Windows 11 和 Server 2025 中已被标记为弃用,但在大量现存系统中仍然可用
输出格式虽然不如 PowerShell 灵活,但在受限环境中非常实用
3.1 常用 WMIC 查询 wmic process list full — 进程完整信息
1 2 3 4 5 C:\> wmic process list full C :\> wmic process get Name ,ProcessId ,ParentProcessId ,CommandLine /format:csv > C :\IR \processes.csv # 快速筛选 C :\> wmic process where "Name ='powershell.exe '" get ProcessId ,CommandLine
wmic startup list full — 启动项
1 2 3 4 5 6 7 C:\> wmic startup list full # 输出示例: # Caption =SystemUpdate # Command ="C :\ProgramData \Update \svc.exe " -silent # Location =HKLM \SOFTWARE \Microsoft \Windows \CurrentVersion \Run # User =Public
wmic service list brief — 服务概览
1 2 C:\> wmic service list brief C :\> wmic service where "StartMode ='Auto ' and State ='Running '" get Name ,PathName ,StartName
wmic qfe list — 已安装补丁
1 2 3 4 5 6 C:\> wmic qfe list brief # 输出示例: # Description HotFixID InstalledOn # Update KB5035849 3/12/2026 # Security Up KB5034439 2/13/2026
用途: 检查系统补丁级别,结合漏洞利用判断入侵路径
wmic useraccount list — 用户账户
1 2 3 4 5 6 C:\> wmic useraccount list brief # AccountType Description Disabled Domain FullName Name SID # 512 FALSE WEB -SVR01 Administrator S -1-5-21-...500 # 512 TRUE WEB -SVR01 Guest S -1-5-21-...501 # 512 FALSE WEB -SVR01 support $ S -1-5-21-...1003
wmic os get caption,version — 操作系统信息
1 2 3 4 C:\> wmic os get Caption ,Version ,BuildNumber ,OSArchitecture # BuildNumber Caption OSArchitecture Version # 17763 Microsoft Windows Server 2019 Std 64-bit 10.0.17763
其他实用 WMIC 查询
1 2 3 4 5 6 7 8 9 10 11 # 网络适配器 C:\> wmic nicconfig where IPEnabled =TRUE get IPAddress ,MACAddress ,DefaultIPGateway ,DNSServerSearchOrder # 共享目录 C :\> wmic share list brief # 登录会话 C :\> wmic logon get AuthenticationPackage ,LogonType ,Caption # 磁盘信息 C :\> wmic logicaldisk get Caption ,Size ,FreeSpace ,FileSystem
四、实战组合技 以下是常见 IR 场景中的命令组合流程,模拟真实排查思路
场景1:发现异常外连 → 定位进程 → 查看详情 → 分析文件 Step 1:发现异常网络连接
1 2 3 4 5 6 7 8 9 Get-NetTCPConnection -State Established | Where-Object { $_ .RemoteAddress -notmatch '^(127\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.|::1|0\.0\.0\.0)' } | Select-Object RemoteAddress, RemotePort, OwningProcess, @ {N='Process' ;E={(Get-Process -Id $_ .OwningProcess).ProcessName}}, @ {N='Path' ;E={(Get-Process -Id $_ .OwningProcess).Path}} | Format-Table -AutoSize
Step 2:深入分析可疑进程
1 2 3 4 5 6 7 8 9 10 11 Get-CimInstance Win32_Process -Filter "ProcessId=8844" | Select-Object Name, ProcessId, ParentProcessId, CommandLine, CreationDate | Format-List $pid = 8844 while ($pid -ne 0 ) { $proc = Get-CimInstance Win32_Process -Filter "ProcessId=$pid " if (-not $proc ) { break } Write-Host "$ ($proc .ProcessId) | $ ($proc .Name) | $ ($proc .CommandLine)" $pid = $proc .ParentProcessId }
Step 3:分析文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 $file = "C:\ProgramData\Update\svc.exe" Get-FileHash $file -Algorithm SHA256 | Select-Object HashGet-FileHash $file -Algorithm MD5 | Select-Object HashGet-Item $file | Select-Object Name, Length, CreationTime, LastWriteTime, LastAccessTimeGet-AuthenticodeSignature $file Get-Item $file -Stream *[System.Text.Encoding ]::ASCII.GetString([System.IO.File ]::ReadAllBytes($file )) -split '[^\x20-\x7E]+' | Where-Object { $_ .Length -gt 6 } | Select-Object -First 50
Step 4:固定证据
1 2 3 4 5 6 7 8 Copy-Item $file C:\IR\evidence\ -Force Get-CimInstance Win32_Process | Export-Csv C:\IR\processes.csv -NoTypeInformation Get-NetTCPConnection | Export-Csv C:\IR\netconnections.csv -NoTypeInformation
场景2:CPU 100% → 定位挖矿进程 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Id, ProcessName, CPU, @ {N='Memory(MB)' ;E={[math ]::Round($_ .WorkingSet64/1 MB,2 )}}, PathGet-FileHash C:\Windows\Fonts\conhost.exe -Algorithm SHA256Get-AuthenticodeSignature C:\Windows\Fonts\conhost.exeGet-CimInstance Win32_Process -Filter "ProcessId=4456" | Select-Object CommandLineGet-NetTCPConnection -OwningProcess 4456 Get-CimInstance Win32_Process -Filter "ProcessId=4456" | Select-Object ParentProcessId
场景3:可疑 RDP 登录排查 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 query user Get-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4624 ; StartTime=(Get-Date ).AddDays(-7 )} | ForEach-Object { $xml = [xml ]$_ .ToXml() $type = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'LogonType' }).'#text' if ($type -eq '10' ) { [PSCustomObject ]@ { Time = $_ .TimeCreated User = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetUserName' }).'#text' SourceIP = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'IpAddress' }).'#text' LogonId = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetLogonId' }).'#text' } } } | Format-Table -AutoSize Get-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4625 ; StartTime=(Get-Date ).AddDays(-7 )} | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { Time = $_ .TimeCreated User = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetUserName' }).'#text' SourceIP = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'IpAddress' }).'#text' Status = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'SubStatus' }).'#text' } } | Group-Object SourceIP | Sort-Object Count -Descending | Select-Object Count, Name -First 5 Get-WinEvent -LogName 'Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational' -MaxEvents 50 | Select-Object TimeCreated, Id, Message | Format-List
详细事件日志分析见 03-事件日志分析
场景4:全面快速排查(5 分钟 first look) 目标:首次接触可疑机器时,5 分钟内获取全面概况
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 $outDir = "C:\IR\$ (Get-Date -Format 'yyyyMMdd_HHmmss')" New-Item -ItemType Directory -Path $outDir -Force | Out-Null Write-Host "[1/8] 系统信息..." -ForegroundColor Greensysteminfo > "$outDir \systeminfo.txt" whoami /all > "$outDir \whoami.txt" Write-Host "[2/8] 进程列表..." -ForegroundColor GreenGet-CimInstance Win32_Process | Select-Object ProcessId, ParentProcessId, Name, CommandLine, CreationDate | Export-Csv "$outDir \processes.csv" -NoTypeInformation Write-Host "[3/8] 网络连接..." -ForegroundColor GreenGet-NetTCPConnection | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, State, OwningProcess | Export-Csv "$outDir \connections.csv" -NoTypeInformation Write-Host "[4/8] 用户账户..." -ForegroundColor GreenGet-LocalUser | Export-Csv "$outDir \users.csv" -NoTypeInformation Get-LocalGroupMember Administrators > "$outDir \admins.txt" Write-Host "[5/8] 服务列表..." -ForegroundColor GreenGet-WmiObject Win32_Service | Select-Object Name, StartMode, State, PathName, StartName | Export-Csv "$outDir \services.csv" -NoTypeInformation Write-Host "[6/8] 计划任务..." -ForegroundColor GreenGet-ScheduledTask | ForEach-Object { $actions = $_ .Actions [PSCustomObject ]@ { TaskName = $_ .TaskName; TaskPath = $_ .TaskPath; Author = $_ .Author State = $_ .State; Execute = $actions .Execute; Arguments = $actions .Arguments } } | Export-Csv "$outDir \tasks.csv" -NoTypeInformation Write-Host "[7/8] 自启动项..." -ForegroundColor GreenGet-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -EA SilentlyContinue > "$outDir \autoruns_hklm.txt" Get-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -EA SilentlyContinue > "$outDir \autoruns_hkcu.txt" Get-WmiObject -Namespace root\Subscription -Class __EventFilter -EA SilentlyContinue > "$outDir \wmi_filters.txt" Write-Host "[8/8] 最近安全事件..." -ForegroundColor GreenGet-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4624 ,4625 ,4720 ,4732 ,1102 ; StartTime=(Get-Date ).AddDays(-7 )} -MaxEvents 500 -EA SilentlyContinue | Select-Object TimeCreated, Id, Message | Export-Csv "$outDir \security_events.csv" -NoTypeInformation Write-Host "`n[完成] 数据保存在: $outDir " -ForegroundColor Yellow
场景5:持久化全面检查 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 Write-Host "=== Windows 持久化全面排查 ===" -ForegroundColor CyanWrite-Host "`n[1] Registry Run Keys" -ForegroundColor Yellow@ ( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' , 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' , 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' , 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' , 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run' ) | ForEach-Object { $items = Get-ItemProperty $_ -EA SilentlyContinue if ($items ) { Write-Host " $_ " -ForegroundColor Gray; $items } } Write-Host "`n[2] Non-standard Services" -ForegroundColor YellowGet-WmiObject Win32_Service | Where-Object { $_ .PathName -notlike "*\Windows\*" -and $_ .PathName -notlike "*\Program Files*" -and $_ .PathName } | Select-Object Name, PathName, StartMode, State | Format-Table -AutoSize Write-Host "`n[3] Non-Microsoft Scheduled Tasks" -ForegroundColor YellowGet-ScheduledTask | Where-Object { $_ .Author -notlike 'Microsoft*' -and $_ .TaskPath -notlike '\Microsoft\*' } | ForEach-Object { [PSCustomObject ]@ { Name=$_ .TaskName; Path=$_ .TaskPath; Execute=$_ .Actions.Execute; Args=$_ .Actions.Arguments; Author=$_ .Author } } | Format-Table -AutoSize -Wrap Write-Host "`n[4] WMI Event Subscriptions" -ForegroundColor YellowGet-WmiObject -Namespace root\Subscription -Class __EventFilter -EA SilentlyContinue | Format-List Name, QueryGet-WmiObject -Namespace root\Subscription -Class CommandLineEventConsumer -EA SilentlyContinue | Format-List Name, CommandLineTemplateWrite-Host "`n[5] Winlogon" -ForegroundColor YellowGet-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' | Select-Object Shell, UserinitWrite-Host "`n[6] Startup Folders" -ForegroundColor YellowGet-ChildItem "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" -EA SilentlyContinueGet-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" -EA SilentlyContinueWrite-Host "`n[7] IFEO (Debugger hijack)" -ForegroundColor YellowGet-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options' | Get-ItemProperty | Where-Object { $_ .Debugger } | Select-Object PSChildName, Debugger Write-Host "`n[8] AppInit_DLLs" -ForegroundColor YellowGet-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows' | Select-Object AppInit_DLLs, LoadAppInit_DLLs
更多持久化技术详见 Windows应急响应/04-持久化排查
场景6:Web 服务器入侵排查 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Get-ChildItem -Path C:\inetpub\ -Recurse -Include *.aspx,*.ashx,*.asmx,*.asp,*.jsp -Force -EA SilentlyContinue | Where-Object { $_ .LastWriteTime -gt (Get-Date ).AddDays(-7 ) } | Select-Object FullName, LastWriteTime, Length | Sort-Object LastWriteTime -Descending Get-CimInstance Win32_Process | Where-Object { $parent = Get-CimInstance Win32_Process -Filter "ProcessId=$ ($_ .ParentProcessId)" -EA SilentlyContinue $parent .Name -eq 'w3wp.exe' -and $_ .Name -in @ ('cmd.exe' ,'powershell.exe' ,'conhost.exe' ) } | Select-Object ProcessId, Name, CommandLine Get-Content "C:\inetpub\logs\LogFiles\W3SVC1\u_ex$ (Get-Date -Format 'yyMMdd').log" -Tail 100 | Select-String -Pattern '(cmd\.exe|powershell|eval|exec|union.*select|\.\.\/)'
场景7:勒索软件应急 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Get-ChildItem -Path C:\ -Recurse -Force -EA SilentlyContinue -Include *.encrypted,*.locked,*.crypto,*.enc | Measure-Object | Select-Object Count Get-ChildItem -Path C:\ -Recurse -Force -EA SilentlyContinue -Include README*.txt,DECRYPT*.txt,RECOVER*.txt,HOW_TO*.txt | Select-Object FullName vssadmin list shadows Get-CimInstance Win32_Process | Where-Object { $_ .CommandLine -match '(vssadmin|wbadmin|bcdedit|cipher|wmic.*shadowcopy)' } | Select-Object ProcessId, Name, CommandLine
场景8:横向移动检测 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Get-NetTCPConnection -LocalPort 445 ,5985 ,5986 -State Established | Select-Object RemoteAddress, LocalPort, OwningProcess | Format-Table -AutoSize Get-Service -Name 'PSEXESVC' -EA SilentlyContinueGet-WinEvent -FilterHashtable @ {LogName='System' ; ID=7045 } -EA SilentlyContinue | Where-Object { $_ .Message -like '*PSEXESVC*' -or $_ .Message -like '*psexec*' } Get-WinEvent -FilterHashtable @ {LogName='Security' ; ID=4648 ; StartTime=(Get-Date ).AddDays(-7 )} -MaxEvents 100 | ForEach-Object { $xml = [xml ]$_ .ToXml() [PSCustomObject ]@ { Time = $_ .TimeCreated Subject = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'SubjectUserName' }).'#text' Target = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetUserName' }).'#text' TargetServer = ($xml .Event.EventData.Data | Where-Object {$_ .Name -eq 'TargetServerName' }).'#text' } } | Format-Table -AutoSize net use net session
五、Linux vs Windows 命令对照表 此表面向有 Linux IR 经验的工程师,快速找到 Windows 等价命令
Linux
Windows CMD
Windows PowerShell
用途
ps aux / ps -ef
tasklist /v
Get-CimInstance Win32_Process
进程列表(含命令行)
ps -ef --forest
N/A
自定义脚本(见场景1)
进程树
kill -9 <pid>
taskkill /PID <pid> /F
Stop-Process -Id <pid> -Force
强杀进程
ss -tulnp / netstat -tulnp
netstat -ano
Get-NetTCPConnection
网络连接
ip addr
ipconfig /all
Get-NetIPAddress
IP 地址
ip route
route print
Get-NetRoute
路由表
arp -n
arp -a
Get-NetNeighbor
ARP 表
cat /etc/resolv.conf
ipconfig /all
Get-DnsClientServerAddress
DNS 配置
dig / nslookup
nslookup
Resolve-DnsName
DNS 查询
cat /etc/passwd
net user
Get-LocalUser
用户列表
id / groups
whoami /all
[System.Security.Principal.WindowsIdentity]::GetCurrent()
当前用户信息
w / who
query user
quser
在线用户
getent group sudo
net localgroup Administrators
Get-LocalGroupMember Administrators
管理员列表
last / lastlog
N/A
Get-WinEvent -FilterHashtable @{LogName='Security';ID=4624}
登录历史
find / -name *.exe
dir /s /a *.exe
Get-ChildItem -Recurse -Include *.exe
文件搜索
find / -mtime -1
forfiles /D +<date>
GCI -Recurse | ? {$_.LastWriteTime -gt (date).AddDays(-1)}
最近修改文件
md5sum / sha256sum
certutil -hashfile <f> SHA256
Get-FileHash
文件哈希
ls -la
dir /a
Get-ChildItem -Force
含隐藏文件列表
lsattr
attrib
Get-ItemProperty
文件属性
strings
N/A(用 sysinternals strings)
自定义(见场景1)
字符串提取
lsof -p <pid>
tasklist /m /fi "PID eq <pid>"
Get-Process -Id <pid> -Module
进程加载模块
systemctl list-units
sc query type= service state= all
Get-Service
服务列表
systemctl cat <svc>
sc qc <svc>
Get-WmiObject Win32_Service -Filter "Name='<svc>'"
服务详情
crontab -l
schtasks /query /fo list /v
Get-ScheduledTask
计划任务
uname -a
systeminfo
Get-ComputerInfo
系统信息
env
set
Get-ChildItem Env:
环境变量
journalctl
wevtutil qe System
Get-WinEvent -LogName System
系统日志
/var/log/auth.log
Security Event Log
Get-WinEvent -LogName Security
认证日志
iptables -L
netsh advfirewall show allprofiles
Get-NetFirewallRule
防火墙规则
mount
net use
Get-SmbMapping
挂载/映射
chkrootkit / rkhunter
N/A(用 Autoruns、GMER)
N/A
Rootkit 检测
核心差异提醒:
Linux 一切皆文件,Windows 还有注册表、WMI、COM 等隐藏的持久化位置
Linux 权限是 rwx + setuid,Windows 是 ACL + Token Privileges + UAC
Linux 进程用 fork/exec,Windows 用 CreateProcess,父子进程关系在 Windows 中更有分析价值
Linux 日志在 /var/log/ 文本文件,Windows 日志是二进制 EVTX 格式需专用工具解析
Windows 有大量 GUI 工具(Sysinternals Suite)在紧急情况下比命令行更高效
六、补充工具推荐 Sysinternals Suite(必备) Process Explorer — 图形化进程管理器,可查看进程树、DLL、句柄、VirusTotal 集成
Autoruns — 最全面的自启动项查看工具,覆盖 100+ 持久化位置
TCPView — 实时网络连接监控
Process Monitor (ProcMon) — 实时文件/注册表/网络活动监控
Strings — Windows 版 strings 命令
AccessChk — 权限检查工具
下载:https://docs.microsoft.com/en-us/sysinternals/
1 2 3 4 5 6 # 命令行下载(如果有网络) C:\> powershell -c "Invoke -WebRequest -Uri 'https ://download.sysinternals.com /files /SysinternalsSuite.zip ' -OutFile C :\Tools \Sysinternals.zip " C :\> powershell -c "Expand -Archive C :\Tools \Sysinternals.zip C :\Tools \Sysinternals "# 或直接从 live.sysinternals.com 运行 C :\> \\live.sysinternals.com \tools \autorunsc.exe -a * -c -h -s -t > C :\IR \autoruns.csv
其他推荐工具 KAPE (Kroll Artifact Parser and Extractor) — 自动化取证采集
Velociraptor — 端点取证与响应平台
Eric Zimmerman's Tools — 各种 Windows 取证解析工具
CyLR — 快速取证采集工具
winpmem — Windows 内存采集
参考与关联 Windows应急响应/01-基础知识
03-事件日志分析
Windows应急响应/04-持久化排查
Windows应急响应/05-Webshell排查
02-排查命令速查