analyzing-powershell-script-block-logging
できること
このツールは、PowerShellのログを分析して、怪しい、または偽装されたコマンドを見つけ出します。Windowsで悪意のあるコードを実行するために、ハッカーが使う手口を探します。
使う場面
- ✓セキュリティインシデントを調査しているとき。
- ✓危険な活動を検知するためのアラートを作成しているとき。
- ✓既知の攻撃をセキュリティ対策が捉えられているかを確認したいとき。
スキルのリンク
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-powershell-script-block-logging/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このPowerShellのログファイルを分析して、怪しい点がないか教えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
ツールはPowerShellのログを読み込み、分割されていたスクリプトの断片をつなぎ合わせ、エンコードされたコマンドやセキュリティを無効化する試みなど、一般的な攻撃パターンを探します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Analyzing PowerShell Script Block Logging
When to Use
- When investigating security incidents that require analyzing powershell script block logging
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Familiarity with security operations concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Instructions
- Install dependencies:
pip install python-evtx lxml - Collect PowerShell Operational logs:
Microsoft-Windows-PowerShell%4Operational.evtx - Parse Event ID 4104 entries using python-evtx to extract ScriptBlockText, ScriptBlockId, and MessageNumber/MessageTotal for multi-part script reconstruction.
- Apply detection heuristics:
- Base64-encoded commands (
-EncodedCommand,FromBase64String) - Download cradles (
DownloadString,DownloadFile,Invoke-WebRequest,Net.WebClient) - AMSI bypass patterns (
AmsiUtils,amsiInitFailed) - Obfuscation indicators (high entropy, tick-mark insertion, string concatenation)
- Base64-encoded commands (
- Generate a report with reconstructed scripts, risk scores, and MITRE ATT&CK mappings.
python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json
Examples
Detect Encoded Command Execution
import base64
if "-encodedcommand" in script_text.lower():
encoded = script_text.split()[-1]
decoded = base64.b64decode(encoded).decode("utf-16-le")
Reconstruct Multi-Block Script
Scripts split across multiple 4104 events share a ScriptBlockId. Concatenate blocks ordered by MessageNumber to recover the full script.
よくある質問
「スクリプトブロックログ」とは何ですか?
PowerShellがコマンドを実行したときに、Windowsが作成する詳細な記録です。何が実行されたのかを把握するのに役立ちます。
「Living off the Land」の手法とは何ですか?
攻撃者が、PowerShellなどの正規のWindowsツールを悪用して、追加の悪意のあるソフトウェアを入れずに攻撃を行う手法のことです。
この文脈での「エントロピー」とは何ですか?
文字列がどれだけランダムで「ばらばら」に見えるかを示す指標です。エントロピーが高いテキストは、コマンドが本来の目的を隠すために符号化されている可能性を示します。
詳細
作者による元の説明
Parse Windows PowerShell Script Block Logs (Event ID 4104) from EVTX files to detect obfuscated commands, encoded payloads, and living-off-the-land techniques. Uses python-evtx to extract and reconstruct multi-block scripts, applies entropy analysis and pattern matching for Base64-encoded commands, Invoke-Expression abuse, download cradles, and AMSI bypass attempts.
人気
- GitHubのスター
- 35k
- ランキング
- #7646
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
gitcrawl
394k保存されたGitHubのイシューとプルリクエストのアーカイブを検索し、重複をまとめ、GitHub上の現在の状態を確認するようエージェントを支援します。
slacrawl
394kローカルのSlackアーカイブ内のメッセージを検索して件数を数え、アーカイブの新しさを確認し、必要に応じて更新するようエージェントを支援します。
goplaces
394kGoogle Placesを使って、場所を検索し、詳細や口コミを取得し、場所の名前を解決するようエージェントを支援します。スクリプト用にJSON出力もできます。