
Why attackers love PowerShell (high-level)
- Native & trusted: Ships with Windows, blends into admin ops (ATT&CK: T1059.001).
- Memory-heavy workflows: Can operate file-less; fewer on-disk artefacts.
- Remote automation: WinRM/PSRemoting can pivot laterally if poorly governed.
- Evasion surface: Obfuscation, encoded commands, and attempts to bypass AMSI.
Tactical tells of malicious use (what to hunt)
- Long Base64-encoded command lines (
-enc,-e, unusual 400–4000 char blobs). - Non-interactive launches from office apps, browsers, scripting hosts, or archives.
- PowerShell v2 engine usage (deprecated; often targeted).
- AMSI errors in logs or script-block failures that coincide with process spawns.
- Bursty remote sessions (WinRM) to many hosts from one workstation.
Turn on the lights (logging to enable)
- Script Block Logging (Event ID 4104) and Module Logging (ID 4103).
- PowerShell Transcription (captures raw input/output).
- Process creation (Windows 4688) + command-line auditing.
- Sysmon (Events 1, 3, 7, 11, 13, 15, 22) for process/DLL/network/file and AMSI.
- PowerShell v2 disablement (Group Policy), and prefer PowerShell 7 for admins.
Keep logs for at least 30–90 days; forward to SIEM with host labels (tier, owner).
Block what you can (preventive controls)
- WDAC / AppLocker: Allow-list signed admin tools and approved scripts only.
- ASR Rules (Defender): Block Office from creating child processes; block obfuscated scripts; block credential theft.
- Constrained Language Mode: Apply via WDAC/AppLocker for non-admins.
- JEA (Just Enough Administration): Role-scoped endpoints limiting cmdlets/params.
- Remove local admin where not required; enforce MFA on remote management.
Quick SIEM hunts (safe, detection-only)
- Encoded command usage
- Idea: Look for
powershell.exe/pwsh.exewith-encor-encodedcommand, especially when parent is Office, browser, Teams, PDF reader, archive tool.
- Idea: Look for
- Abnormal parent/child chains
- Idea: Office/Acrobat/7zip/WinRAR → PowerShell → new process.
- PowerShell v2 invocations
- Idea: Image path contains
WindowsPowerShell\v1.0plus-Version 2or DLL load ofSystem.Management.Automationv2.
- Idea: Image path contains
- AMSI failures
- Idea: Events indicating AMSI init or scan errors correlated with blocked events.
If you want, I can drop ready-to-paste KQL/Sigma detection snippets tailored to your SIEM—just say which platform (Defender, Sentinel, Splunk, Elastic).
Incident response playbook (high-level)
- Triage: Isolate host; snapshot volatile data (netstat, running procs, PS history).
- Scope: Hunt for the same command line on other hosts; check WinRM logs.
- Contain: Revoke tokens/sessions; disable compromised accounts; block C2 IOCs.
- Eradicate: Remove persistence (scheduled tasks, WMI, Run keys, services).
- Recover: Reimage if integrity is uncertain; restore from clean backups.
- Lessons: Patch gaps (logging, allow-listing, rights model), purple-team test.
Hardening checklist (copy/pin)
- Disable PowerShell v2; mandate PowerShell 7 for admins.
- Enable 4103/4104 logging + Transcription to a central share.
- Deploy WDAC/AppLocker policies (publisher rules).
- Turn on ASR rules and Network Protection.
- Configure JEA for routine admin tasks.
- Require MFA for PSRemoting; restrict by Just-In-Time access.
- Baseline what good looks like (approved scripts, management stations).
- Quarterly purple-team exercises against these detections.
Executive takeaways
- PowerShell is not the enemy—unchecked freedom is.
- Visibility + allow-listing + least privilege beat signature cat-and-mouse.
- Treat administrative tooling like production code: governance, review, logging.
CyberDudeBivash CTA (safe & on-brand)
- Defense Playbooks & Detection Packs: cyberdudebivash.com/latest-tools-services-offered-by-cyberdudebivash/
- Daily Threat Intel: cyberbivash.blogspot.com
- Need bespoke PowerShell hardening & SIEM content? I’ll ship it.
#PowerShellSecurity #BlueTeam #ThreatHunting #WindowsDefense #SIEM #EDR #ASR #AppLocker #WDAC #JEA #CISO #CyberDefense #CyberDudeBivash
Leave a comment