IPBan – The Simplest Way to Block Hackers and Bot Nets




IPBan for Windows Donation

Is your server getting hacked? Do you need to block ip addresses automatically? Dealing with a brute force attack? Don’t want to spend your life savings on SysPeace or other overly priced security software? IPBan is for you.

A while ago, I noticed a disturbing trend in the event viewer on one of our dedicated Windows servers. We were getting thousands of failed login attempts to terminal services (remote desktop). I decided I would enable the terminal services auto-ban, so after 5 login attempts the ip address would get banned for 24 hours. This only solved part of the problem, as the attacker continued to flood our server with requests, causing the windows logon process (csrss.exe kept appearing and disappearing in task manager) to continually spin up and shut down. This actually caused significant CPU (10%+) and disk IO as the event viewer continually wrote failed login attempts.

After searching the Interwebs for a better way, I did not find anything that I liked or that didn’t spike my CPU usage, so I decided to make a free (if you install it yourself) tool in C# to auto-ban ip addresses. This tool is constantly improving. Right now it can block ip addresses as found in the event log for audit-failure events. It is very configurable as well.

Features include:
– Unlimited number of ip addresses to ban
– Duration to ban ip address
– Number of failed login attempts before ban
– Whitelist of comma separated ip addresses or regex to never ban
– Blacklist of comma separated ip addresses or regex to always ban
– Custom prefix to windows firewall rules
– Custom keywords, XPath and Regex to parse event viewer logs for failed login attempts
– Refreshes config so no need to restart the service when you change something
– Highly configurable, ban anything that comes through Windows Event Viewer
– A GREAT and FREE (if you install it yourself) alternative to RdpGuard or Syspeace
– Contains configuration to block Remote Desktop attempts, Microsoft SQL Server login attempts and MySQL Server login attempts by default
– Runs on Linux and Windows

If you found IPBan useful, would you consider helping support the project by donating? Thank you for your consideration.

I am also willing to do contracting work to improve IPBan if it doesn’t fit your needs or to help you set it up on your servers. Please email me at [email protected] if you would like paid services.

*INSTRUCTIONS*: https://github.com/jjxtra/IPBan




Windows IPBan Donation

Need help configuring IPBan? I’m happy to help with simple questions. For more involved assistance, I do consulting. Please email me at [email protected] and I’d be happy to consider your proposal.

Testimonials:

A few days ago I was checking the event logs for my server that hosts a MSSQL DB. I could see that I was under attack by a port scanner (changing IP addresses for each attack ‘period’). I know I should not have MSSQL exposed to the world but the users are remote so it was the easiest solution for me. Anyway, I came across IPBAN. Because of the concise directions on your Git repository I was able to easily setup a service. The results were immediate, as the banlog.txt file had an entry immediately after starting the service, thus putting an end to the current attack. The purpose of this email is simply to express my gratitude for developing the program. The people responsible for the attack are the lowlifes of the internet while you are on the complete opposite side of the scale! Thank you, thank you, thank you for the help.

– Jim

Bravo! This is a master piece!

– Periklis

Really a neat tool. This really works as advertised, and wow does it cut down on the noise. Your code structure made it really easy as well to add a couple lines to immediately ban non-US IPs (using a 3rd party geocoding service). Thanks for this great tool.

– Matt C

Sign up for the IPBan Mailing List




Windows IPBan Donation
4.5 2 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

408 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Chris
Chris
1 year ago

Lovely Program! I am a personal free user. Is there a forum discussing how to use the program.. Stuck with what program to run on ban (windows 11/10) Google hasn’t helped.

sumber
sumber
1 year ago

Hello
I have tried “RPD shield” but it cannot block IP on vps which use Port forwarding to access RDP.
will it workng with port forwading vps?
warm regards

Patrick
3 years ago

Your IPBan solution is awesome!!!
I’ve been using IPBan for quite some time now and I just installed the Pro version, which saves me a lot of configuration on different servers.

I will certainly make a donation.

Keep up the good work !!

docbt
docbt
3 years ago

Hi guys! I need help with windows event viewer logs. I can´t get it to work and I don´t know why. I would like two add two things: VPN and SVN login attempts. 1. VPN: VPN 0x80000000000000 System //EventID ^20271$ //Provider[@Name=’RemoteAccess’] //Data //Data <![CDATA[ (?.*?) ]]> //Data <![CDATA[ (?.+) ]]> //Data //Data event log xml looks like this for example: 20271 3 0 0x80000000000000 424153 System server.domain.com {NA} Admin 123.123.123.123 Die Remoteverbindung wurde verweigert, weil die angegebene Kombination aus Benutzername und Kennwort nicht erkannt wird oder das ausgewählte Authentifizierungsprotokoll nicht für den RAS-Server zulässig ist. 0x10 B3020000 2.SVN SVN 0x80000000000000… Read more »

docbt
docbt
3 years ago
Reply to  Jeff Johnson

Hi jjxtra!

Thx. I created an issue.

https://github.com/DigitalRuby/IPBan/issues/89

Greetings doc

steve
steve
4 years ago

this dead?

steve
steve
4 years ago
Reply to  Jeff Johnson

Thanks! /releases link helped! Amazing work, testing it out now.
Where can i find what “pro” does ?

jean paganucci
jean paganucci
4 years ago

Good evening, jjxtra, great work with IPBan, I’m already using on several clients, I’m getting this log “2019-06-04 21: 36: 07.3749 | WARN | DigitalRuby.IPBan.IPBanLog | IP 81.171.98.177,, RDP ban pending. ” It’s already a few minutes, what would it be? thank you so much again.

Paul
Paul
4 years ago

Awesome program jjxtra!, just joined mailing list and installed on my win2016 term server for testing. I used your application years back but it looks like it has come a long way, keep up the good work. Will donate after testing and looking forward to the GUI!

Julian
Julian
4 years ago

Hi everyone, Great program and good potential! Tried to set IPBAN up for Kerio Connect mail server log files. I set it up to react on these 2 scenarios (text lines from mail server log): 1) IMAP: Invalid password for user [email protected]. Attempt from IP address 186.xxx.xxx.xxx. 2) SMTP: User [email protected] doesn’t exist. Attempt from IP address 186.xxx.xxx.xxx. The config is regex is set up like this : Attempt\sfrom\sIP\saddress\s(?.?) So it reacts to both these with one regex but the IP address extracted is wrong. Running IPBan returns this : 2019-05-11 23:13:31.7582|WARN|DigitalRuby.IPBan.IPBanLog|Login failure: 0.0.0.1, , Kerio, 88 2019-05-11 23:13:31.7582|WARN|DigitalRuby.IPBan.IPBanLog|IP 0.0.0.1,… Read more »

Julian
Julian
4 years ago
Reply to  Jeff Johnson

Thanks a lot for the link. The created regex didn’t work, but gave me the solution to my problem !

Thanks a lot for your help – and a very quick answer.

Best regards
Julian

Vlad
Vlad
4 years ago

Great work,  almost or even better f2b. Thank you!

I have some questions,  i found in config file settings for Ipban pro, i changed it for my needs but nothing, does that settings work ?  Where i can by pro and i need some additional functionality, not for free of course,  need online connection monitoring smth like ntop on linux.

Thank again.

Vlad
Vlad
4 years ago
Reply to  Jeff Johnson

and why there is no usernames in db ((

Jaymer
Jaymer
4 years ago

Thats whats odd… it IS adding the IP to the Windows Firewall IP list (from what I can tell).  I sent you several files.  Hope you can find something.

Am having trouble Replying on this site.  Clicking REPLY doesn’t really do anything.  I manually moved down to the comments windows at the bottom so I don’t know if this is going to make a new thread or reply to you.

jaymer
jaymer
4 years ago
Reply to  Jeff Johnson

hey, I can reply now! sent you screencap of my rules.

Jaymer
Jaymer
4 years ago

Followup: Maybe what is confusing me is terminology… Take this line from logfile.txt 2019-04-24 19:54:35.5069|WARN|DigitalRuby.IPBan.IPBanLog|Login attempt failed: 185.156.177.220, , RDP, 60 I see this IP has been added to an IPBAN Rule in Windows Firewall by your process.  Thats awesome.  This was their 60th attempt. But for the logfile to say “Login attempt failed” means [to me] they actually got thru a firewall and tried to login to an account, and failed.  Instead, maybe the msg should be “Connection blocked by IPBAN Firewall rule” – that would make me (and someone else viewing the log) more comfortable. I was also… Read more »

Jaymer
Jaymer
4 years ago

Hi Installed the latest version (as of April 2019) on Windows Server 2012. Within 1 hour, I have 150 IPs added to banlist – am viewing the SqlLite table. One offending IP is now up to a count of 68 FailedLoginCount. How can that be? Wouldn’t he stop getting this far if he was blocked after 5 attempts – I think I first saw this IP when the count was 12. Makes we wonder if they are really getting blocked. The IPAddress shows as an invisible blob (with only a few entries having graphic symbols). IPAddressText is viewable. I did… Read more »

Hans
Hans
4 years ago

Awesome, looking forward to it! Additional notes: Even though I set the limit to max. 5 failed login attempts, I see some logs where it says “count: 12” etc. Is it a bug from you or a logging issue? I use Windows Server 2012. Furthermore, my own IP got banned, even though I did not have any failed attempts on my own server. The log: 2019-04-16 16:08:31.9999|WARN|IPBan.IPBanLog|Login attempt failed: MY IP, , RDP, 3 2019-04-16 16:08:48.7317|WARN|IPBan.IPBanLog|Banning ip address: MY IP, user name: , config black listed: False, count: 5, extra info: Very strange, goes from 3 to 5 and does… Read more »

Hans
Hans
4 years ago

Good afternoon,

would you consider to implement a function that restricts connections just to specific countries?

For example: You allow connections to your RDP just from 3 countries, let’s say Germany, Netherlands and Poland. Connections made from other countries get instantly blocked.

If you see connections made from Brazil, China or other “weird” countries you would probably never connect from, then you get my point.

Will
Will
5 years ago

Nice! Was just trying to figure out if wail2ban would work on server 2016 then I found you. Look forward to testing it out.

Dan Brown
5 years ago

I Would gladly Donate once I have figured out how it works. I am not a Programmer. One thing I did learn was that I have been looking for a reason why my Customers scanner would scan to any workstation but not the Server.Eventually I found the Scanner IP Address in the Firewall IPban rule but was puzzled as to how it got there because it scans using port 445 and not 3389. I would gladly also contribute to developement of a GUI for us self taught people. It is Obviously working as I see a list of Banned IP… Read more »

Steve Ricketts
Steve Ricketts
5 years ago

I just downloaded the latest version.  I have tons of 5152 “Filtering Packet Drop” errors in the event log.  I’ve put the following in the IPBan.dll.config file:

<!– This group will block audit failures from failed login attempts to Windows –>
<Group>
<Source>RDP</Source>
<Keywords>0x8010000000000000</Keywords>
<Path>Security</Path>
<Expressions>

<Expression>
<XPath>//EventID</XPath>
<Regex>^(4625|5152)$</Regex>
</Expression>

<Expression>
<XPath>//Data[@Name=’IpAddress’ or @Name=’Workstation’]</XPath>
<Regex>
<![CDATA[
(?<ipaddress>.+)
]]>
</Regex>
</Expression>
</Expressions>
</Group>

Why am I still getting those errors and why is IPBan not putting those IP’s in the ban list?

Steve Ricketts
Steve Ricketts
5 years ago
Reply to  Jeff Johnson


5152
0
0
12809
0
0x8010000000000000

22470986

Security
Eterna


0

%%14592
176.119.4.49
55188
192.168.100.2
5002
6
103153
%%14597
13

Steve Ricketts
Steve Ricketts
5 years ago
Reply to  Steve Ricketts

Maybe if I take off part of the tags they will show…
– Event xmlns=”http://schemas.microsoft.com/win/2004/08/events/event”>
– System>
Provider Name=”Microsoft-Windows-Security-Auditing” Guid=”{54849625-5478-4994-A5BA-3E3B0328C30D}” />
EventID>5152/EventID>
Version>0/Version>
Level>0/Level>
Task>12809/Task>
Opcode>0/Opcode>
Keywords>0x8010000000000000/Keywords>
TimeCreated SystemTime=”2019-01-10T11:52:43.914718600Z” />
EventRecordID>22470986/EventRecordID>
Correlation />
Execution ProcessID=”4″ ThreadID=”88″ />
Channel>Security/Channel>
Computer>Eterna/Computer>
Security />
/System>
– EventData>
Data Name=”ProcessId”>0/Data>
Data Name=”Application”>-/Data>
Data Name=”Direction”>%%14592/Data>
Data Name=”SourceAddress”>176.119.4.49/Data>
Data Name=”SourcePort”>55188/Data>
Data Name=”DestAddress”>192.168.100.2/Data>
Data Name=”DestPort”>5002/Data>
Data Name=”Protocol”>6/Data>
Data Name=”FilterRTID”>103153/Data>
Data Name=”LayerName”>%%14597/Data>
Data Name=”LayerRTID”>13/Data>
/EventData>
/Event>

Steve Ricketts
Steve Ricketts
5 years ago
Reply to  Jeff Johnson

Sorry… had to repost without “real” xml. Hopefully, you can delete the bad one below.

Steve Ricketts
Steve Ricketts
5 years ago
Reply to  Jeff Johnson

That seems to have helped a lot, Thanks!!

David Borneman
David Borneman
5 years ago

Hi, First off, great tool! I am curious where this stores its list of banned IPs in order to maintain the firewall rules properly? I see no files being written in the application folder, and it obviously didn’t install a SQL database of any kind… is this stuff just held in memory? I am looking to hook in to that in some manner so that I can report those banned IPs to a master database, so I can identify IPs that are being banned multiple times and/or hitting multiple servers, so I can perma-ban those IPs in our hardware firewall.… Read more »

Vaughan Wickham
5 years ago

Hello,

I would like to be able to block failed Outlook Web Access logon attempts.

The default config file is not blocking these failed attempts

Regards

VW

Vaughan Wickham
5 years ago

Hello,

I have downloaded v1_3_5

I am using Windows

I found a short tutorial here but I can’t find the entries mentioned in the tutorial with regards to logging and log rotation.

Also, if you have plans for a GUI and a supported version, I would be interested in licensing details

Thank you

VW