一、explorer.exe 用户归属查询(优化版)
Powershell
复制
需以管理员身份运行
1. 获取所有explorer.exe 进程的详细信息(含用户和路径)
$explorerProcesses = Get-CimInstance Win32_Process -Filter “Name=‘explorer.exe’” | ForEach-Object {
$owner = Invoke-CimMethod -InputObject $_ -MethodName GetOwner | Select-Object -ExpandProperty User
[PSCustomObject]@{
ProcessId = $.ProcessId
User = $owner
ExecutablePath = $.ExecutablePath
CommandLine= $_.CommandLine
}
}
2. 输出带颜色标记的检查结果
KaTeX parse error: Expected '}', got 'EOF' at end of input: …ject { if (.ExecutablePath -ne “$env:Windir\explorer.exe”) {
Write-Host "[异常] PID
(
(
(.ProcessId) | 用户:
(
(
(.User) | 路径:
(
(
(.ExecutablePath)" -ForegroundColor Red
} else {
Write-Host “[正常] PID
(
(
(.ProcessId) | 用户:
(
(
(.User)” -ForegroundColor Green
}
}
二、远程连接服务关联分析(增强版)
Powershell
复制
3. 深度检测网络连接及服务关联性
$remotePorts = @(3389, 5938, 6568) # RDP、TeamViewer、AnyDesk默认端口
$networkConnections = Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue |
Where-Object { $.RemotePort -in $remotePorts -or $.OwningProcess -in $explorerProcesses.ProcessId }
4. 进程与服务映射(表格化输出)
$networkConnections | ForEach-Object {
$process = Get-Process -Id $.OwningProcess -ErrorAction SilentlyContinue
$service = Get-CimInstance Win32_Service | Where-Object ProcessId -eq $.OwningProcess
[PSCustomObject]@{
LocalIP = $_.LocalAddress
RemoteIP = $_.RemoteAddress
Port = $_.RemotePort
ProcessName = $process.Name
ServiceName = if ($service) { $service.Name } else { "N/A" }
ServiceDisplayName = if ($service) { $service.DisplayName } else { "非服务进程" }
}
} | Format-Table -AutoSize -Wrap
5. 自动生成威胁评分
r
i
s
k
S
c
o
r
e
=
0
i
f
(
riskScore = 0 if (
riskScore=0if(networkConnections) { KaTeX parse error: Expected 'EOF', got '}' at position 17: …iskScore += 40 }̲ if (explorerProcesses.ExecutablePath -contains $false) { $riskScore += 60 }
Write-Host "`n[安全评估] 当前风险指数: $riskScore/100 " -ForegroundColor
(
i
f
(
(if (
(if(riskScore -gt 50) { “Red” } else { “Yellow” })
三、关键结果解读与应对
输出类型 正常特征 风险特征 响应动作
进程路径正常 路径为C:\Windows\explorer.exe 路径包含Temp或随机字符串目录 立即终止进程 → 使用taskkill /F /PID 1234
RDP连接合法 远程IP为企业内网地址(如10.1.1.1) 连接至未知国家IP(如185.153.76.2立陶宛) 防火墙阻断 → New-NetFirewallRule -DisplayName “BlockMalicious” -RemoteAddress $ip -Action Block
高威胁服务 服务名为TermService(系统RDP服务) 服务名模仿系统服务(如TermServic少字母) 禁用服务 → sc config “恶意服务名” start=disabled
四、自动化日志记录(可选)
Powershell
复制
将结果记录到安全审计日志
l
o
g
P
a
t
h
=
"
logPath = "
logPath="env:USERPROFILE\Desktop\SecurityAudit_$(Get-Date -Format ‘yyyyMMdd-HHmm’).log"
$explorerProcesses | ConvertTo-Json | Out-File -FilePath $logPath -Append
$networkConnections | ConvertTo-Json | Out-File -FilePath $logPath -Append
Write-Host “`n[日志存档] 审计结果已保存至: $logPath” -ForegroundColor Cyan
总结
优化后的指令实现:
多维度数据整合:进程路径、用户身份、网络连接、服务注册表四重关联分析;
风险可视化:通过颜色标记和威胁评分快速定位问题;
防御闭环:从检测到阻断的完整操作建议。
若检测到以下情况,需启动应急响应:
explorer.exe 进程由SYSTEM用户运行且连接外部IP → 可能为提权后门;
风险评分超过70分 → 建议立即隔离主机并启动内存取证分析(使用Volatility工具)