Giter Club home page Giter Club logo

psfail2ban's Introduction

PSFail2Ban

Powershell script to block IP addresses after multiple failed logon attempts.

How to install

Download all scripts in any folder and run (with administrative privileges):

Install-ScheduledTask.ps1

This will create a scheduled task to run Update-FirewallRule.ps1 (see below) every hour.

How it works

The main script is Update-FirewallRule.ps1. It checks for Event ID 4625 entries in Windows Security logs and adds a blocking rule in Windows Firewall for every IP address with 10 or more failed logons.

Also, all blocked IPs will be saved in a blacklist.txt. You can change this file if needed. Addresses in this file will ALWAYS be blocked by the firewall rule even if they didn't show up in Security events.

In the same way, you could keep a whitelist.txt. Addresses in this file will NEVER be blocked by the firewall rule.

By default the script will check only the last 6 hours in Security log. You can use the -LastHours parameter to change this number.

Other tools

If you want a quick summary of failed logins, just run

Get-FailedLogons.ps1

This will show the number of failed logons attempts for each source IP address.

Alternatively, you can run it with -ShowUsernames parameter

Get-FailedLogons.ps1 -ShowUsernames

which will show the same result but now grouped by usernames.

By default the script will check only the last 6 hours in Security log. You can use the -LastHours parameter to change this number.

psfail2ban's People

Contributors

fdcastel avatar styletronix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.