首页/安全/应急响应速查/PowerShell 4104 脚本块日志

PowerShell 4104 脚本块日志

开启 ScriptBlockLogging 后 4104 记录脚本块内容,可还原混淆脚本的真实逻辑;前提是策略在事发前已启用。

应急响应速查安全更新于 2026-10-12
事件4104(PowerShell/Operational 通道)
姊妹事件4103 模块日志、400 引擎启动
前提ScriptBlockLogging 已启用
用途还原混淆/无文件攻击的实际代码

查询脚本块与检查策略

查询脚本块与检查策略
Get-WinEvent -LogName 'Microsoft-Windows-PowerShell/Operational' -MaxEvents 200 -ErrorAction SilentlyContinue | Where-Object { $_.Id -eq 4104 } | Select-Object -First 10 TimeCreated, Message | Format-List
Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -ErrorAction SilentlyContinue
没启用策略就查不到 4104;这类日志属于「事前准备型」证据,事后无法补录。

易错点

  • 事后才找 4104:策略未启用则完全无记录
  • 终端直接看超长消息:先导出文件再读,避免截断

数据来源与参考

  • Microsoft Learn:PowerShell 脚本块日志
  • MITRE ATT&CK T1059.001 PowerShell

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌