Spacebar Campaigns

WL-004 PowerShell 4104 PowerShell Script Block Logging

Log ID:
WL-004
Source:
PowerShell
Representative Path:
Applications and Services Logs > Microsoft > Windows > PowerShell > Operational (Event ID 4104)
Collection:
Winlogbeat
Primary Use:
파일 다운로드 명령어나 난독화된 스크립트 등 실제 실행된 PowerShell 코드 블록 전체를 감사(Audit)하여 난독화 우회 및 외부 도구 반입 행위를 실시간 탐지

주요 필드

필드의미예시
winlog.event_idPowerShell 감사 이벤트 식별자 (스크립트 블록 로깅의 경우 값은 4104)4104
winlog.computer_name스크립트가 실행된 대상 시스템(호스트)의 식별 이름FS01.mycompany.local
winlog.event_data.ScriptBlockText프로세스 메모리 내에서 실행된 전체 스크립트 내용 또는 명령어 원문 코드 블록다운로드 및 실행 PowerShell 스크립트(...New-Item -ItemType Directory -Force C:\\Users\\Public\\Downloads...)
winlog.event_data.ScriptBlockId분할되어 기록된 스크립트 블록들을 연결하고 식별하기 위한 고유 ID9b6edbe6-5eb8-465f-adb3-e0895e74593e

커버하는 Techniques Used

TechniqueMapping Reason
T1105 - Ingress Tool Transfer공격자가 후속 공격(예: Kerberoasting)에 사용할 악성 도구(Rubeus.exe 등)를 반입하기 위해 외부 C2 서버나 웹 서버로부터 파일 다운로드 함수 및 커맨들릿을 실행하는 과정을 PowerShell 스크립트 감사 로그 수준에서 정확하게 포착하고 매핑한다.

탐지 포인트

Technique관찰할 행위주요 필드
T1105 - Ingress Tool Transfer파일 서버 및 내부 호스트에서 PowerShell을 이용해 네트워크 너머의 외부 자원을 끌어오는 웹 요청 함수나 유틸리티(Invoke-WebRequest, DownloadFile 등)가 실행되는 행위 감시(특히 분석가나 모니터링의 눈을 피하기 위해 약어인 iwr, curl, wget 등을 사용하여 파일 다운로드를 은밀히 시도하는 패턴 집중 분석)winlog.event_id, winlog.computer_name, winlog.event_data.ScriptBlockText, winlog.event_data.ScriptBlockId

ELK Query 예시

host.name: "FS01.mycompany.local"
and event.code: "4104"
and (
  message: "*Invoke-WebRequest*"
  or message: "*iwr*"
  or message: "*DownloadFile*"
  or message: "*Start-BitsTransfer*"
  or message: "*curl*"
  or message: "*wget*"
)