Communitygithub.com

PowerShell 스크립트 블록 로깅 분석

Windows PowerShell 스크립트 블록 로그(이벤트 ID 4104)를 EVTX 파일에서 파싱하고 분석합니다.

PowerShell 스크립트 블록 로깅 분석란 무엇인가요?

이 스킬은 보안 분석가가 Windows 이벤트 로그(EVTX)에서 PowerShell 스크립트 블록 로깅(이벤트 ID 4104)을 추출, 파싱 및 분석할 수 있도록 지원합니다. python-evtx 및 lxml 라이브러리를 사용하여 Microsoft-Windows-PowerShell%4Operational.evtx 파일에서 ScriptBlockText, ScriptBlockId, MessageNumber 및 MessageTotal 필드를 추출하고, 여러 이벤트에 걸쳐 분할된 PowerShell 스크립트를 재구성합니다. 또한 Base64 인코딩 명령, 다운로드 크래들, AMSI 우회 패턴, 난독화 지표와 같은 일반적인 악성 패턴을 탐지하는 휴리스틱을 적용합니다. 분석 결과는 재구성된 스크립트, 위험 점수 및 MITRE ATT&CK 매핑과 함께 JSON 보고서로 생성되어 보안 운영 및 위협 헌팅 워크플로우에 통합될 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-powershell-script-block-logging

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

PowerShell 스크립트 블록 로깅 분석은(는) 무엇을 하나요?

사용 시기

  • PowerShell 스크립트 블록 로깅 분석이 필요한 보안 사고를 조사할 때
  • 이 도메인에 대한 탐지 규칙 또는 위협 헌팅 쿼리를 구축할 때
  • SOC 분석가가 이 분석 유형에 대한 구조화된 절차가 필요할 때
  • 관련 공격 기술에 대한 보안 모니터링 범위를 검증할 때

전제 조건

  • 보안 운영 개념 및 도구에 대한 숙련도
  • 안전한 실행을 위한 테스트 또는 실습 환경에 대한 접근 권한
  • 필수 종속성이 설치된 Python 3.8+
  • 모든 테스트 활동에 대한 적절한 권한

지침

  1. 종속성 설치: pip install python-evtx lxml
  2. PowerShell 운영 로그 수집: Microsoft-Windows-PowerShell%4Operational.evtx
  3. python-evtx를 사용하여 이벤트 ID 4104 항목을 파싱하여 ScriptBlockText, ScriptBlockId 및 다중 부분 스크립트 재구성을 위한 MessageNumber/MessageTotal을 추출합니다.
  4. 탐지 휴리스틱 적용:
    • Base64 인코딩 명령 (-EncodedCommand, FromBase64String)
    • 다운로드 크래들 (DownloadString, DownloadFile, Invoke-WebRequest, Net.WebClient)
    • AMSI 우회 패턴 (AmsiUtils, amsiInitFailed)
    • 난독화 지표 (높은 엔트로피, 따옴표 표시 삽입, 문자열 연결)
  5. 재구성된 스크립트, 위험 점수 및 MITRE ATT&CK 매핑이 포함된 보고서를 생성합니다.
python scripts/agent.py --evtx-file /path/to/PowerShell-Operational.evtx --output ps_analysis.json

예제

인코딩된 명령 실행 탐지

import base64
if "-encodedcommand" in script_text.lower():
    encoded = script_text.split()[-1]
    decoded = base64.b64decode(encoded).decode("utf-16-le")

다중 블록 스크립트 재구성

여러 4104 이벤트에 분할된 스크립트는 동일한 ScriptBlockId를 공유합니다. MessageNumber 순서대로 블록을 연결하여 전체 스크립트를 복구합니다.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

관련 스킬