Skip to main content

Detecting Malicious PowerShell Scripts With Free Tools

PowerShell is a favorite tool for attackers. It's built into every modern Windows environment, trusted by default, and incredibly powerful for running scripts, downloading payloads, and moving laterally.


But here's the good news: you don't need expensive endpoint detection solutions to start catching malicious PowerShell activity. With a few free tools, you can immediately gain valuable visibility and improve your detection capabilities.


Here's a simple setup I've used in resource-constrained environments like K–12 schools:


Step 1: Install Sysmon for Detailed Logging

Why Sysmon?

Windows Event Logs capture some data, but Sysmon (from Microsoft's Sysinternals suite) provides much richer detail: process creation, command-line arguments, network connections, and more.


How to install Sysmon:

  1. Download from Microsoft Sysinternals: Sysmon.
  2. Run: sysmon -accepteula -i sysmonconfig.xml

(Use a community config like SwiftOnSecurity's sysmon config to get started quickly.)


What to watch for:

  • Event ID 1 (Process creation) with PowerShell command-line arguments.
  • Flags like -enc (encoded command), -nop (no profile), or -w hidden.


Step 2: Forward Logs to a Central Location

Why centralize logs?

You'll miss the bigger picture if you only look at local event logs. Forwarding logs lets you correlate and spot trends across your entire environment.


Options (all free):

  • Windows Event Forwarding (WEF): Built into Windows, no additional cost. Configure clients to forward specific events (like Sysmon Event ID 1).
  • Central server/collector: A simple Windows Server VM can be your log collector.
  • Elastic Stack (free tier) or Wazuh: Both offer more advanced search/alerting if you're comfortable setting them up.


Step 3: Create Simple Detection Rules

You don't need a SIEM to start detecting suspicious PowerShell. Even scheduled tasks or scripts can alert you.

What to look for:

  • PowerShell with encoded commands: powershell.exe -enc <base64 string>
  • Suspicious keywords in command lines:
    • Invoke-Mimikatz
    • DownloadString
    • Invoke-Expression
  • Use regex or simple string matching in your collector/analysis tool.


Example detection with Elastic (Kibana):

Search query:

process.command_line: ("-enc" OR "Invoke-Mimikatz" OR "DownloadString")


Step 4: Test Your Setup

One of the best ways to validate detections is to simulate an attack (safely).


Example test command (non-malicious):

powershell -nop -w hidden -enc SQBFAFgAUABMAE8ASQBU

(This is just base64 for "EXPLOIT" — safe to run for testing.)


Check if your Sysmon logs capture it and whether your alert triggers.


Real-World Example

This setup caught a suspicious script trying to use Invoke-Mimikatz in one of my environments. The attempt was stopped quickly because we had visibility without a commercial EDR product.


Closing Thoughts

Education and other budget-constrained organizations often feel at a disadvantage when it comes to cybersecurity. But visibility doesn't have to cost thousands.


By combining Sysmon, Windows Event Forwarding, and simple rules, you can start detecting malicious PowerShell activity today — at zero cost.


Security isn't always about the fanciest tool. Sometimes, it's about using what you already have in more innovative ways.

Over to you: What free or low-cost tricks have you used to catch suspicious activity?

Comments

Popular posts from this blog

Why Securing Things “Backwards” Is So Difficult in K–12 IT

Many K–12 districts are facing a difficult reality: after years of convenience-first technology use, the time has come to adopt a more secure, structured approach. Cyber insurance requirements are tightening. State and federal regulations are growing. Threats are increasing. And school systems are expected to modernize their security posture quickly and without disrupting learning. But strengthening security in a district that has operated with wide-open access for years isn’t just a technical challenge; it’s a cultural renovation. Transitioning from “anything goes” to “secured by design” is one of the hardest shifts for schools to make. Not because people don’t care about security, but because securing things backwards means undoing years of habits, expectations, and legacy decisions. Here’s why it’s so difficult , and how districts can make the transition without breaking what’s working. Why Securing Things Backwards Is Hard 1. You’re Taking Away What People Are Used To When classr...

Incident Response for Schools: Why Playbooks Matter

When a cybersecurity incident occurs, such as a phishing email, ransomware outbreak, or accidental exposure of student data, the first few minutes are crucial. Yet, many school districts lack a clear, step-by-step plan for responding. The result? Confusion, delayed decisions, extended downtime, and even compliance failures. That’s why every school should have Incident Response (IR) playbooks : simple, one-page guides that outline who to call, what to do, and how to contain and recover from common incidents. Why Playbooks Are Critical in Schools Clarity Under Pressure: When panic sets in, playbooks provide structure. Staff know exactly what steps to take. Consistency: Every incident is handled the same way, reducing the risk of mistakes. Compliance: For Kansas schools, ITEC 7230a requires incident response planning and documentation. Playbooks help districts meet that standard. Framework Alignment: The NIST Cybersecurity Framework (CSF) 2.0 emphasizes Respond as o...

Vendor and Third-Party Risk Management in K–12: Protecting Student Data Beyond Your Walls

Modern school districts rely on hundreds of third-party applications, ranging from learning management systems and browser extensions to assessment platforms and parent communication tools. Each of these vendors connects to your network, accesses your data, or processes sensitive student information. Every one of them represents potential risk. While internal defenses like patching, MFA, and backups are essential, vendor risk management ensures your district is protected from vulnerabilities that originate outside your network . Why Vendor Risk Management Matters for Schools School technology ecosystems have expanded rapidly over the last decade. What used to be a handful of software systems is now a web of cloud tools, integrations, and data sharing agreements. Without strong oversight, this complexity creates real-world risk: Data Breaches via EdTech Vendors: Many school breaches occur not from internal attacks, but through compromised third-party systems. Privacy Compliance Exp...