powershell-logging
/powershell-logging
Włącza i analizuje logowanie PowerShell, czyli bloki skryptów, moduły, transkrypcję i AMSI, by wykrywać podejrzane polecenia.
- Autor
- kaandgnsh ↗
- Repozytorium
- Claude-Blue ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 01.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 3
Brak sygnałów. Repozytorium zmienione 01.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Włącza i analizuje logowanie PowerShell, czyli bloki skryptów, moduły, transkrypcję i AMSI, by wykrywać podejrzane polecenia.
Oryginalny opis (EN)
Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
Jak działa
- Enable (GPO: Administrative Templates → Windows Components → Windows PowerShell)
- What to hunt in 4104/4688
- Queries
- Sigma example
- Related skills
- References
Podgląd SKILL.md
---
name: powershell-logging
description: Enable and analyze PowerShell telemetry — script block logging (4104), module logging (4103), transcription, AMSI — to detect encoded commands, download cradles, obfuscation and downgrade attacks. Use when investigating malicious PowerShell, reviewing logging configuration, or writing PowerShell detections.
license: MIT
metadata:
category: windows-security
version: "2.0.0"
verification: documented
---
# PowerShell Logging and Analysis
## Enable (GPO: Administrative Templates → Windows Components → Windows PowerShell)
| Setting | Event | Value |
|---|---|---|
| Turn on PowerShell Script Block Logging | 4104 in `Microsoft-Windows-PowerShell/Operational` | Decoded, deobfuscated script content at execution |
| Turn on Module Logging (`*`) | 4103 | Pipeline execution details |
| Turn on PowerShell Transcription | Text files | Full session I/O; write to a protected share |
| Protected Event Logging (optional) | — | Encrypts 4104 content with a certificate |
PowerShell 5+ automatically logs "suspicious" script blocks at Warning level even without the policy. PowerShell 7 logs to `PowerShellCore/Operational`.
## What to hunt in 4104/4688
- Encoded commands: `-enc`, `-EncodedCommand`, `-e ` with long base64; decode: `[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($b64))`.
- Download cradles: `IEX`, `Invoke-Expression`, `DownloadString`, `DownloadFile`, `Net.WebClient`, `Invoke-WebRequest ... | iex`, `Start-BitsTransfer`.
- AMSI bypass strings: `AmsiUtils`, `amsiInitFailed`, `AmsiScanBuffer` patching.
- Defender tampering: `Set-MpPreference -DisableRealtimeMonitoring $true`, `Add-MpPreference -ExclusionPath`.
- Downgrade: `powershell.exe -version 2` (bypasses script block logging; remove the PowerShell v2 feature).
- Credential tools: `Invoke-Mimikatz`, `sekurlsa`, `Get-GPPPassword`, `Invoke-Kerberoast`.
- Large script blocks are split across multiple 4104 events (`MessageNumber`/`MessageTotal`, same `ScriptBlockId`) — reassemble before analysis.
## Queries
Sentinel (MDE): `DeviceProcessEvents | where FileName in~ ("powershell.exe","pwsh.exe") and ProcessCommandLine matches regex @"(?i)\s-(e|en|enc|enco|encod|encode|encoded|encodedc|encodedcommand)\s+[A-Za-z0-9+/=]{40,}"`
Splunk: `index=wineventlog source="XmlWinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104 (ScriptBlockText="*DownloadString*" OR ScriptBlockText="*AmsiUtils*")`
## Sigma example
```yaml
title: PowerShell Script Block With AMSI Bypass Strings
id: 2b6f0c8e-9d3f-4c55-8c0f-6f1f0a8f3b21
status: experimental
description: Detects script blocks referencing AMSI bypass primitives.
references:
- https://learn.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal
author: Claude-Blue
date: 2026-10-31
tags:
- attack.defense-impairment
- attack.t1685
logsource:
product: windows
category: ps_script
detection:
selection:
ScriptBlockText|contains:
- 'AmsiUtils'
- 'amsiInitFailed'
- 'AmsiScanBuffer'
condition: selection
falsepositives:
- Security tooling and research scripts
level: high
```
## Related skills
`script-deobfuscation`, `windows-event-log-analysis`, `sigma-authoring`, `lolbin-hunt`
## References
- Microsoft about_Logging_Windows: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows
- MITRE ATT&CK T1059.001: https://attack.mitre.org/techniques/T1059/001/
Wersje
W bazie nie ma innych skilli o nazwie powershell-logging.
Migawka bazy z 13.11.2026 · wersja paczki cf8e663ea0df (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100detecting-suspicious-powershell-execution
Szuka podejrzanego wykonania PowerShell, np. zakodowanych poleceń i skryptów pobierających, w telemetrii EDR i w SIEM. - 100threat-hunting-powershell-cmd-execution-traces
Szuka zaciemnionych poleceń PowerShell, zakodowanych skryptów i linii poleceń pobierających pliki w zapisanych logach. - 96write-script-powershell
Prowadzi pisanie skryptów PowerShell i musi być używany za każdym razem, gdy powstaje taki skrypt. - 96powershell
Pomaga w tworzeniu skryptów PowerShell, automatyzacji Windows, modułów i zadań administracyjnych, także na wielu platformach. - 90powershell-security-hardening
Wzmacnia automatyzację PowerShell: bezpieczne zdalne zarządzanie, zasadę najmniejszych uprawnień i zgodność skryptów z bazowymi wymaganiami bezpieczeństwa. - 100powershell
Egzekwuje firmowe standardy kodowania PowerShell przy pisaniu, przeglądzie i debugowaniu skryptów PS1: struktura, obsługa błędów, bezpieczeństwo, wydajność i wzorce wyjścia.