WiredPulse / Invoke-Fail2Ban

PowerShell version of Fail2Ban
11 stars 2 forks source link

PowerShell version of Fail2Ban

This script monitors a Windows system for attempted brute force authentications. After the defined number of failures have occured, the script will create a firewall rule to block the IP for a defined period of time. Additionally, when an IP is banned, the event is written to the system's event log under and stored in a queryable SQL DB. The IP(s) of the system that is running the script are automatically whitelisted with the ability to add additional IPs to the whitelist.

Usage

  1. Download repo and unzip repo
  2. Edit script with your favorite text editor and adjust configs just after initial comment, as desired
  3. Save scrip and execute it
  4. Follow the options (see screenshots below)

Configurable options

Screenshots


Running the script
Alt text

Configuring the Whitelist (single IP or CIDR blocks)
Alt text

Monitoring and banning
Alt text

Banned IP in Event Log
Alt text

Banned IP firewall rule(begins with "ban") Alt text

Retrieving banned IPs through the script Alt text

Retrieving banned IPs within the SQL DB Alt text

Removing all banned IPs before their expiration Alt text