mcpField
D
detecting-fileless-attacks-on-endpoints

detecting-fileless-attacks-on-endpoints

github.com/mukul975セキュリティ35.2k60 回インストール8 週間前に更新
リポジトリ

detecting-fileless-attacks-on-endpoints について

エンドポイント防御担当者向けのファイルレス攻撃検出スキルです。テレメトリーの設定や、PowerShell、プロセスインジェクション、WMI永続化、レジストリ実行の検出を扱います。ファイル型マルウェアの検出向けではありません。

主な機能

  1. 01SysmonとPowerShellログの設定
  2. 02AMSIによるスクリプト内容の検査
  3. 03PowerShell攻撃の兆候検出
  4. 04プロセスインジェクションイベントの関連付け
  5. 05WMIとレジストリ永続化の特定

活用シーン

  1. 01悪意あるファイルが見つからない事案の調査
  2. 02ファイルレス攻撃検出ルールの作成
  3. 03エンドポイントテレメトリー設定の確認
  4. 04PowerShellやWMI攻撃の脅威ハンティング

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill detecting-fileless-attacks-on-endpoints

インストール後、Claude Code で/detecting-fileless-attacks-on-endpointsを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

詳細

エンドポイントでのファイルレス攻撃の検出

使用するタイミング

次の場合にこのスキルを使用します:

  • メモリ内で完全に動作するファイルレスマルウェアの検出ルールを構築する
  • PowerShell ベースの攻撃、リフレクティブ DLL インジェクション、WMI の悪用をハンティングする
  • ファイルレス攻撃の兆候を取得するために、エンドポイントテレメトリ(Sysmon、AMSI、PowerShell ログ)を設定する
  • 従来型の AV では悪意のあるファイルが見つからなかったインシデントを調査する

ファイルベースのマルウェアの検出や、マルウェアのリバースエンジニアリングには使用しないでください。

前提条件

  • プロセス作成と WMI イベントのログ記録を有効にした Sysmon
  • PowerShell のスクリプトブロックログとモジュールログを有効化
  • スクリプトコンテンツの検査用に AMSI(Antimalware Scan Interface)を有効化
  • 動作検出機能を備えた EDR(MDE、CrowdStrike、SentinelOne)

ワークフロー

ステップ 1:必要なテレメトリを有効にする
# Enable PowerShell Script Block Logging (GPO or registry)
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" `
  -Name EnableScriptBlockLogging -Value 1 -PropertyType DWORD -Force

# Enable PowerShell Module Logging
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging" `
  -Name EnableModuleLogging -Value 1 -PropertyType DWORD -Force

# Enable PowerShell Transcription
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription" `
  -Name EnableTranscripting -Value 1 -PropertyType DWORD -Force

# Sysmon config for fileless detection (key events):
# Event ID 1: Process creation (captures CommandLine)
# Event ID 7: Image loaded (DLL loading)
# Event ID 8: CreateRemoteThread (injection)
# Event ID 10: Process access (LSASS access)
# Event ID 19/20/21: WMI events
ステップ 2:PowerShell ベースの攻撃を検出する
# Indicators of malicious PowerShell:

# Encoded command execution
EventID: 1
CommandLine contains: "powershell" AND ("-enc" OR "-e " OR "-encodedcommand" OR "FromBase64String")

# Download cradle patterns
CommandLine contains: "IEX" AND ("Net.WebClient" OR "DownloadString" OR "Invoke-WebRequest")
CommandLine contains: "Invoke-Expression" AND "New-Object"

# AMSI bypass attempts (Event ID 4104 - Script Block)
ScriptBlock contains: ("Amsi"+"Utils") OR ("amsi"+"InitFailed") OR "SetValue.*amsi"

# Splunk query for suspicious PowerShell:
index=windows source="WinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104
| where match(ScriptBlockText, "(?i)(iex|invoke-expression|downloadstring|net\.webclient|frombase64|bypass|amsi.utils)")
| table _time host ScriptBlockText
ステップ 3:プロセスインジェクション手法を検出する
# Reflective DLL injection - loads DLL from memory without touching disk
# Detection: Sysmon Event 7 (ImageLoaded) where image path is unusual
EventID: 7
ImageLoaded NOT starts with: "C:\Windows\" AND NOT starts with: "C:\Program Files"

# Process hollowing - creates process in suspended state, replaces memory
# Detection: Process creation followed by immediate memory write
EventID: 1 + 10 correlation
# Process created then accessed with PROCESS_VM_WRITE

# APC injection - queues code to thread's async procedure call queue
# Detection: Sysmon CreateRemoteThread from non-system process
EventID: 8
SourceImage NOT IN (known_legitimate_sources)

# MDE KQL:
DeviceEvents
| where ActionType in ("CreateRemoteThreadApiCall", "NtAllocateVirtualMemoryApiCall")
| where InitiatingProcessFileName !in ("MsMpEng.exe", "svchost.exe")
| project Timestamp, DeviceName, ActionType, InitiatingProcessFileName,
    InitiatingProcessCommandLine, FileName
ステップ 4:WMI ベースの永続化を検出する
# Sysmon Event IDs 19/20/21 for WMI events
EventID: 19  # WmiEventFilter activity detected
EventID: 20  # WmiEventConsumer activity detected
EventID: 21  # WmiEventConsumerToFilter activity detected

# Any WMI event subscription creation is suspicious unless expected
# Common malicious WMI persistence:
Consumer contains: "CommandLineEventConsumer" OR "ActiveScriptEventConsumer"

# Query for WMI subscriptions via osquery or PowerShell:
Get-WMIObject -Namespace root\Subscription -Class __EventFilter
Get-WMIObject -Namespace root\Subscription -Class __EventConsumer
Get-WMIObject -Namespace root\Subscription -Class __FilterToConsumerBinding
ステップ 5:レジストリベースの実行を検出する
# Malware stored in registry values and executed via PowerShell
# Sysmon Event 13 - Registry value set with encoded content
EventID: 13
TargetObject contains: "CurrentVersion\Run"
Details: unusually long value or Base64-encoded content

# Detection query:
index=sysmon EventCode=13
| where match(Details, "[A-Za-z0-9+/=]{100,}")
| table _time host TargetObject Details Image

主要な概念

用語定義
ファイルレスマルウェア実行ファイルをディスクに書き込まず、メモリ内で完全に動作するマルウェア
AMSIAntimalware Scan Interface。セキュリティ製品が実行前にスクリプトコンテンツを検査できる Windows API
リフレクティブ DLL インジェクションファイルベースの検出を回避するため、DLL をディスクではなくメモリから読み込むこと
プロセスホローイング正規のプロセスを中断状態で作成し、そのメモリを悪意のあるコードに置き換えること
スクリプトブロックログ難読化解除後のスクリプトコンテンツを取得する PowerShell のログ機能(イベント ID 4104)

ツールとシステム

  • Sysmon:カーネルレベルでプロセス、DLL、WMI を監視
  • AMSI:Windows のスクリプトコンテンツ検査 API
  • PowerShell ログ:スクリプトブロック、モジュール、トランスクリプションのログ
  • Microsoft Defender for Endpoint:ファイルレス手法の動作検出
  • Volatility 3:インシデント後のファイルレスマルウェア分析に用いるメモリフォレンジック

よくある落とし穴

  • ファイルベースの AV に依存する:ディスク上のファイルをスキャンする従来型の AV では、ファイルレス攻撃を完全に見逃します。動作検出と AMSI が必要です。
  • PowerShell ログが無効になっている:スクリプトブロックログがなければ、難読化解除された PowerShell コマンドを防御側が確認できません。
  • AMSI バイパスを検出できない:高度な攻撃者はペイロードの実行前に AMSI をバイパスします。AMSI バイパスの試みを優先度の高いアラートとして検出してください。
  • WMI イベントを監視していない:WMI による永続化は APT グループに好まれる手法です。Sysmon イベント 19~21 を有効にする必要があります。

コメント