蓝队规则系列 - T1021 横向移动:Windows远程管理服务

admin 2024年12月2日22:35:29评论12 views字数 5404阅读18分0秒阅读模式

蓝队规则系列 - T1021 横向移动:Windows远程管理服务

全文共计2087字,预计阅读10分钟

在本系列文章中,我们将探讨基于Mitre ATT&CK框架的TTP战术,如何在不同环境(云、企业、ICS)和场景下制定行之有效的检测规则,并且围绕实际攻击场景检测响应调优展开。

本文将介绍「T1021.006 横向移动:Windows远程管理服务」检测的规则编写,帮助安全团队提高针对Windows环境的防护能力场景。

蓝队规则系列 - T1021 横向移动: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的搜索语句。例如:

蓝队规则系列 - T1021 横向移动:Windows远程管理服务
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远程管理服务

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年12月2日22:35:29
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   蓝队规则系列 - T1021 横向移动:Windows远程管理服务https://cn-sec.com/archives/3460521.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息