全文共计2087字,预计阅读10分钟
在本系列文章中,我们将探讨基于Mitre ATT&CK框架的TTP战术,如何在不同环境(云、企业、ICS)和场景下制定行之有效的检测规则,并且围绕实际攻击场景、检测、响应与调优展开。
本文将介绍「T1021.006 横向移动:Windows远程管理服务」检测的规则编写,帮助安全团队提高针对Windows环境的防护能力场景。
介绍
Mitre ATT&CK框架将攻击过程分为多个阶段,从初始访问、信息收集、权限提升再到数据泄漏,每个阶段都包括多个战术和技术。
具体到「Windows环境,攻击者可能利用有效账户通过Windows远程管理(WinRM)与远程系统进行交互,进而以登录用户的身份执行操作」。
类别
-
战术名称: Windows远程管理服务
-
适用平台: Windows
场景
横向移动:Windows远程管理服务 (T1021.006) :WinRM既是Windows服务的名称,也是允许用户与远程系统交互的协议(例如,运行可执行文件、修改注册表、修改服务)。攻击者可能通过winrm命令或Evil-Winrm工具调用,实现远程命令执行。
检测和响应
案例一
以攻击工具Evil-Winrm的检测为例,以下规则依据Evil-Winrm工具内的硬编码字符串,通过PowerShell模块日志检测Evil-WinRM的执行
title: Evil-WinRm Execution
id: 12345678-9abc-def0-1234-56789abcdef0
description: Detects the execution of Evil-WinRM via PowerShell Module logs by leveraging the hardcoded strings inside the utility.
references:
- https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb
- https://github.com/search?q=repo%3AHackplayers%2Fevil-winrm++shell.run%28&type=code
logsource:
product: windows
category: ps_module
detection:
selection_wsm:
ContextInfo|contains:
- ':WindowsSystem32wsmprovhost.exe'
- ':WindowsSysWOW64wsmprovhost.exe'
selection_payload_1:
Payload|contains:
- value=(get-location).path # https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb#L592
- value=(get-item*).length # https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb#L490
- 'Invoke-Binary ' # https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb#L740
- Donut-Loader -process_id*-donutfile # https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb#L761
- Bypass-4MSI
- IEX ([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($a))).replace('???','')
selection_payload_2:
Payload|contains|all:
- $servicies = Get-ItemProperty "registry::HKLMSystemCurrentControlSetServices "
- Where-Object {$_.imagepath -notmatch "system" -and $_.imagepath -ne $null } | Select-Object pschildname,imagepath
selection_payload_3:
Payload|contains|all:
- $a += "$($_.FullName.Replace('\','/'))/"}else{ $a += "$($_.FullName.Replace('\', '/'))" } # https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb#L1001
- $a=@();$
condition: selection_wsm and 1 of selection_payload_*
falsepositives:
- Legitimate testing. Confirm with the user.
level: high
tags:
- attack.lateral-movement
- attack.t1021.006
日志源:Windows Powershell日志
告警等级:高
误报(False Postive):合规的测试行为,需要与用户确认。
响应步骤
-
隔离受影响的系统:立即将受感染的机器从网络中断开,以防止进一步的恶意活动。
-
识别来源:确定攻击者如何获得访问权限。检查是否有被攻破的账户或被利用的漏洞。
-
分析日志:查看PowerShell日志、WinRM日志和其他相关系统日志,以了解攻击的范围和执行的操作。
案例二
检测WinRM(wsmprovhost.exe)生成的可疑进程。
title: Suspicious Processes Spawned by WinRM
id: 12345678-9abc-def0-1234-56789abcdef0
description: Detects suspicious processes including shells spawnd from WinRM host process
references:
- https://research.splunk.com/endpoint/a081836a-ba4d-11eb-8593-acde48001122/
logsource:
product: windows
category: process_creation
detection:
selection:
ParentImage|endswith: 'wsmprovhost.exe'
Image|endswith:
- 'cmd.exe'
- 'sh.exe'
- 'bash.exe'
- 'powershell.exe'
- 'pwsh.exe'
- 'wsl.exe'
- 'schtasks.exe'
- 'certutil.exe'
- 'whoami.exe'
- 'bitsadmin.exe'
condition: selection
- Legitimate WinRM usage
level: high
tags:
- attack.lateral-movement
- attack.t1021.006
日志源:Windows进程日志
告警等级:中
误报(False Postive):合规的WinRM使用。
响应步骤
-
终止可疑进程:使用任务管理器或命令行工具终止由wsmprovhost.exe生成的可疑进程。
-
分析日志:检查系统日志、PowerShell日志和WinRM日志,确定可疑进程的来源和行为。
规则转换
推荐使用sigma-convert (https://github.com/marirs/sigma-convert),或者在线工具sigconverter (https://sigconverter.io/),将Sigma Rule转化为相应SIEM的搜索语句。例如:
ContextInfo IN ("*:\Windows\System32\wsmprovhost.exe*", "*:\Windows\SysWOW64\wsmprovhost.exe*") Payload IN ("*value=(get-location).path*", "*value=(get-item*).length*", "*Invoke-Binary *", "*Donut-Loader -process_id*-donutfile*", "*Bypass-4MSI*", "*IEX ([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($a))).replace('***','')*") OR (Payload="*$servicies = Get-ItemProperty "registry::HKLM\System\CurrentControlSet\Services\ "*" Payload="*Where-Object {$_.imagepath -notmatch "system" -and $_.imagepath -ne $null } | Select-Object pschildname,imagepath*") OR (Payload="*$a += \"$($_.FullName.Replace('\','/'))/\"}else{ $a += \"$($_.FullName.Replace('\', '/'))\" }*" Payload="*$a=@();$*")
免责申明
本文提到的检测规则仅供学习和讨论使用。我们提供的示例规则和指导并不构成任何形式的正式建议或解决方案。由于每个企业的安全环境和需求都存在差异,我们强烈建议企业根据自身实际情况和环境对这些规则进行针对性修改和充分测试,以确保它们符合您的组织的具体需求和安全要求。
对于因使用或实施这些规则而可能引发的任何问题或损失,我们不承担任何责任。
参考文档
-
Mitre ATT&CK for Enterprise:https://attack.mitre.org/matrices/enterprise
-
A Detailed Guide on Evil-Winrm:https://www.hackingarticles.in/a-detailed-guide-on-evil-winrm/ 介绍了Evil-Winrm的使用
-
Hackplayers/evil-winrm:https://github.com/Hackplayers/evil-winrm/blob/7514b055d67ec19836e95c05bd63e7cc47c4c2aa/evil-winrm.rb Evil-Winrm工具的源码
-
Detection: WinRM Spawning a Process https://research.splunk.com/endpoint/a081836a-ba4d-11eb-8593-acde48001122/ Splunk的检测规则
请关注SecLink安全空间获取我们最新的更新!
原文始发于微信公众号(SecLink安全空间):蓝队规则系列 - T1021 横向移动:Windows远程管理服务
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论