惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Black Hills Information Security, Inc.

Same Problem, Different Angles: When Red Team and Blue Team Actually Talk to Each Other How to Identify and Exploit New Vulnerabilities Swapper – A Pure Regex Match/Replace Burp Extension A Practical Guide to BloodHound Data Collection Network Engineering Basics Signed, Trusted, and Abused: Proxy Execution via WebView2 Getting Started In Pentesting – Advice From The BHIS Pentest Lead Cloud Security: Tips and Resources for Securing the Cloud Lessons From A Chatbot Incident How to Lead Effective Tabletops Understanding GRC: How to Navigate Risks and Compliance Standards The “P” in PAM is for Persistence: Linux Persistence Technique Malware Analysis: How to Analyze and Understand Malware OSINT: How to Find, Use, and Control Open-Source Intelligence What to Do with Your First Home Lab When the SOC Goes to Deadwood: A Night to Remember Social Engineering and Microsoft SSPR: The Road to Pwnage is Paved with Good Intentions Common Cyber Threats Finding the Right Penetration Testing Company Deceptive-Auditing: An Active Directory Honeypots Tool The Curious Case of the Comburglar How to Set Smart Goals (That Actually Work For You) Inside the BHIS SOC: A Conversation with Hayden Covington Abusing Delegation with Impacket (Part 3): Resource-Based Constrained Delegation Why You Got Hacked – 2025 Super Edition Abusing Delegation with Impacket (Part 2): Constrained Delegation Abusing Delegation with Impacket (Part 1): Unconstrained Delegation GoSpoof – Turning Attacks into Intel Model Context Protocol (MCP) Bypassing WAFs Using Oversized Requests Getting Started with AI Hacking Part 2: Prompt Injection Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 2) DomCat: A Domain Categorization Tool Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 1) Microsoft Store and WinGet: Security Risks for Corporate Environments Default Web Content MailFail Commonly Abused Administrative Utilities: A Hidden Risk to Enterprise Security Stop Spoofing Yourself! Disabling M365 Direct Send Bypassing CSP with JSONP: Introducing JSONPeek and CSP B Gone Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource DNS Triage Cheatsheet GraphRunner Cheatsheet Burp Suite Cheatsheet Impacket Cheatsheet Wireshark Cheatsheet Hashcat Cheatsheet EyeWitness Cheatsheet Nmap Cheatsheet Netcat (nc) Cheatsheet Hunt for Weak Spots in Your Wireless Network with Airodump-ng from the Aircrack-ng Suite Detecting ADCS Privilege Escalation Vulnerability Scanning with Nmap Getting Started with NetExec: Streamlining Network Discovery and Access How to Use Dirsearch Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 3: Arcanum Cyber Security Bot How to Design and Execute Effective Social Engineering Attacks by Phone Abusing S4U2Self for Active Directory Pivoting Why Use a Macro Pad? Espanso: Text Replacement, the Easy Way Caging Copilot: Lessons Learned in LLM Security Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 2: Copilot Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 1: Burpference Intercepting Traffic for Mobile Applications that Bypass the System Proxy How to Root Android Phones Communicating Security to the C-Suite: A Strategic Approach Offline Memory Forensics With Volatility Getting Started with AI Hacking: Part 1 Go-Spoof: A Tool for Cyber Deception How to Test Adversary-in-the-Middle Without Hacking Tools Canary in the Code: Alert()-ing on XSS Exploits How to Hack Wi-Fi with No Wi-Fi Why Your Org Needs a Penetration Test Program Burp Suite Extension: Copy For Light at the End of the Dark Web Wi-Fi Forge: Practice Wi-Fi Security Without Hardware Avoiding Dirty RAGs: Retrieval-Augmented Generation with Ollama and LangChain Gone Phishing: Installing GoPhish and Creating a Campaign 5 Things We Are Going to Continue to Ignore in 2025 John Strand’s 5 Phase Plan For Starting in Computer Security Questions From a Beginner Threat Hunter GRC for Security Managers: From Checklists to Influence AI Large Language Models and Supervised Fine Tuning Attack Tactics 9: Shadow Creds for PrivEsc w/ Kent & Jordan One Active Directory Account Can Be Your Best Early Warning Introduction to Zeek Log Analysis Indecent Exposure: Your Secrets are Showing Creating Burp Extensions: A Beginner’s Guide Pitting AI Against AI: Using PyRIT to Assess Large Language Models (LLMs) The Top Ten List of Why You Got Hacked This Year (2023/2024) ICS Hard Knocks: Mitigations to Scenarios Found in ICS/OT Backdoors & Breaches Intro to Data Analytics Using SQL Finding Access Control Vulnerabilities with Autorize The Detection Engineering Process Cyber Risk Lessons We Can Learn From Hurricane Preparedness Intro to Desktop Application Testing Methodology What Is Penetration Testing? Adversary in the Middle (AitM): Post-Exploitation Pentesting, Threat Hunting, and SOC: An Overview QEMU, MSYS2, and Emacs: Open-Source Solutions to Run Virtual Machines on Windows
PowerShell Logging for the Blue Team
2016-12-12 · via Black Hills Information Security, Inc.

Joff Thyer //  

It is no secret that PowerShell is increasingly being used as an offensive tool for attack purposes by both Red Teamers and Criminals alike. Thanks to the efforts of a number of people in the industry, we have tools like PowerSploit, PowerShell Empire, MailSniper, and Bloodhound just to name a few of the top contenders. While most of these tools are definitely post-exploitation in nature, the ability of Red Teamers, and attackers to trivially social engineer end users provides an easy path to extensive PowerShell usage.

Windows 7 is still prevalent in enterprise environments with the default installation version of PowerShell at 2.0. Unfortunately, this version of PowerShell provides no real event logging ability, thus leaving defenders largely blind with the exception of one PowerShell script signing policy.

Fortunately for defenders, Microsoft has responded with significant PowerShell logging enhancements in the Windows Management Framework (WMF) starting with version 4.0, and version 5.0. If an organization is using Windows 10, then the Windows Management Framework is already installed at version 5.0. For those organizations still at Windows 7, it is advisable to upgrade all workstations to WMF version 5.0 bring PowerShell also up to version 5. In addition, Windows 7 has a dependency on dot NET version 4.5 in order to install WMF 5.0. Once this is completed, there are some additional event logging features enabled which include the following:

  1. Module Logging: logs PowerShell pipeline execution details during execution including variable initialization, and command invocation. Module logging is able to record some de-obfuscated scripts, and also some output data. This form of logging has actually been available since PowerShell 3.0 and will log all events to Event ID 4103.
  2. Script Block Logging: logs and records all blocks of PowerShell code as they are executing. The full contents of the code, including the entire script, and all commands are captured. Script block logging also captures all de-obfuscated code due to the object-oriented nature of its implemented. For example, if a script is base64 encoded using the “-Encoded” command argument, script block logging will log the actual decoded script block during execution. Unlike module logging, script block logging does not log the output from executed scripts. If an event exceeds the maximum event log message size, script block logging will split the logged events into multiple events. Additionally, in PowerShell 5.0, script block logging will log events that match a list of suspicious commands at a logging level of “warning”. The normal logging level will be “verbose” or “informational” when enabled. The “suspicious” events will be logged regardless unless script block logging is explicitly disabled. All script block logging events are logged as event ID 4104. In addition to this event, there is an option to log script block execution start and stop events as event ID 4105, and 4106. In my experimentation, enabling this option also provides little additional benefit at the cost of many more events being logged, thus I chose to leave this option disabled.
  3. Full Transcription Logging: logs a full transcript of every single PowerShell session with input and output data. The transcripts are written to individual files with a naming convention that prevents name collisions. It is important to note that transcription only records what appears in the PowerShell terminal windows which does include the contents of scripts or output written directly to the file system. While the transcripts are written by default to the documents folder, this is configurable. It would be advisable to write the transcripts to something like a network share to avoid being deleted and/or modified by an attacker.

After performing the required upgrade to WMF 5, and PowerShell 5 (if using Windows 7), the next step is to enable the logging options. All of these options can be enabled through group policy, however, be aware that the appropriate Windows 10 administrative template files need to be installed before the group policy options will be visible. Not being a former Windows system administrator, I struggled through this for a while before I found the administrative template download located at this Microsoft web page.

https://www.microsoft.com/en-us/download/details.aspx?id=48257

Note that after installation of the administrative templates, your task is not over. All that the installation actually does is copy the files into the “\Program Files (x86)\Microsoft Group Policy” directory. It is up to you to move the appropriate “PowerShellExecutionPolicy.admx”, and the “PowerShellExecutionPolicy.adml” into the correct locations on your system. In a domain environment, the SYSVOL can also be used to deploy administrative templates by using the “\\SYSVOL\Policies\Policy Definitions” directory.

After doing this, your local or domain group policy should contain the additional logging options both in the computer, and user configuration areas. The path to the configuration under each area is:

Policies -> Administrative Templates -> Windows PowerShell

Group Policy Editor Screenshot

Once you have defined these group policy options, the actual events will be logged on the local system in the Applications and Services Logs, as follows:

Applications and Services ->

                Microsoft ->

                        Windows ->

                                PowerShell ->

                                        Operational

The following screenshot was taken after establishing a PowerShell empire session on a remote system. In the process, many different script block log entries were created showing important detailed information on all of the different script blocks being executed. You can also see in this event log that a couple of entries are logged at a “Warning” level indicating potentially suspicious code being executed.

Having said all this, do yourselves a favor, and get WMF 5.0 installed in your environment followed by enabling script block logging at minimum. Friends don’t let friends run PowerShell without logging! Of course, I am assuming that you are all happily planning on collecting these event logs centrally right!?

Happy hunting!