How To: Stop Apache DOS attacks with Fail2Ban

I had to install and configure fail2ban yesterday to stop some hacking attempts on my FTP server, and when I was looking through the fail2ban configs I saw that you could stop DOS (Denial of Service) attacks with it too. As this site’s been hit by the occasional DOS from people with an axe to grind and too much time on their hands, I thought I may as well set up a DOS mitigation strategy while I was at it. Here’s how:

  1. Install fail2ban through the method of your choice.
  2. Edit the file /etc/fail2ban/jail.local and add the following section:

  3. Don’t forget to replace YOUR_WEB_SERVER_ACCESS_LOG with the actual access log for your webserver! Note: This doesn’t have to be an apache log, I just happen to be using apache.

  4. Now we need to create the filter file, so create the file /etc/fail2ban/filters.d/http-get-dos.conf and place the following contents in it:

  5. Now we just need to restart fail2ban for the new jail & filter to come into affect:

  6. Or if your machine is on systemd, use:

    Also on systemd, if you want fail2ban to start on boot (and the chances are that you do), run the additional:

    With all that done your site should be pretty safe from casual DOS attacks, although you’d likely need more stringent maxretry and findtime settings to really help against Distributed DOS (DDOS) attacks.

Testing

To check if fail2ban is seeing the logs, check out /var/log/fail2ban.log and you should see things like:

showing up as visitors view your site.

If you want to test if it’s really working, a nice way to do so is to use ab (Apache Benchmark – part of the apache2-utils package), like this:

This will kick off 500 page-loads in 10 concurrent connections against your site. When the ban kicks in the page-loads will stop (as incoming GET requests from your IP will be dropped), then when the bantime expires you’ll be able to access the site again. If you then take a look in your /var/log/fail2ban.log file you should see something like this:

Pretty neat, huh?

Many thanks to the authors of the following great articles for helping me to get this set up in no-time:
http://www.dedmeet.com/software-projects-mainmenu-12/fail2ban-to-limit-ddos-attacks– on-webserver.html
http://go2linux.garron.me/linux/2011/05/fail2ban-protect-web-server-http-dos-attack-1084.html

Cheers! =D

How To: Block FTP hacking attempts using Fail2Ban

I noticed that my FTP server was getting hit up with huge streams of access attempts, which just won’t do. Thankfully, it’s really easy to block these access attempts using the awesome fail2ban script.

  1. First, install fail2ban either manually or if it’s in your repos use:
  2. Next, go to the relevant section of the file /etc/fail2ban/jail.conf for your FTP server (mine is proftpd) and enable jailing by flipping the enabled flag to true:
  3. Set your retries and bantime as you see fit, and make sure the log file path is correct (i.e. that it’s actually the log you want to monitor!)

  4. Restart fail2ban with a swift:
  5. If your FTP server is controlled via inted/xinetd you don’t need to restart the FTP server as it’s started when required. If your FTP server is standalone then it probably won’t hurt to restart the service manually through /etc/init.d/[your-ftp-server-management-script-here]

That should be pretty much it, if there’s still access attempts going on they’ll be banned from connecting for the bantime you defined, and you’ll be able to see ban details in /var/log/fail2ban.log.

Many, many thanks to the excellent Block FTP Hacking tutorial on The Art of Web – fantastic stuff =D

GTA 4 Carmageddon

This made me smile the other day, so I thought I’d share…

Apparently, you can do this on the PC version just by going into the handling.dat file in your GTA4 folder, and editing “wbias” to be around -9 for all the vehicles you want to go crazy. Something about negative wheel friction, I believe =D

On a title-related bent, I hadn’t thought about the Carmageddon games for a long while – they were pretty cool in their day, but you look now and it’s… well, downright ugly. Still, they used to be a lot of fun to play…

Kevin Butler (re)tweets the PS3 Master Key

Fictional character Kevin Butler is the Sony PS3 spokesperson of sorts – which might lead you to believe that given Sony’s recent sue-a-thon against anyone even daring to mention the hallowed hex digits of the Master Key (Thanks, GeoHot!) – it could, and I’m not an expert, but it could, be a construed as a bad idea for whatever PR firm behind his twitter account (TheKevinButler) to re-tweet said hacked PS3 Master Key.

Which when used correctly will make a PS3 think it’s running legitimate, signed code as opposed to homebrew or warez.

To around 69,000 subscribers.

Kevin Butler PS3 Master Key Retweet

Hahahaha =D Well played, exiva, well played…

Additional: As seen on unixslave.com:

PS3 You Sunk My Battleship

How To: Remove the ZoneAlarm Free Nag Screen

I’ve got some Windows virtual machines I use for when I need to do MS Office stuff or a brief bit of Win32 programming, and noticed earlier that each time I reboot Windows, ZoneAlarm Free decides to nag me to upgrade, and there’s no option to switch it off. In fact, I’d go as far as to say they’d gone a bit talkie-toaster… I can see why they’d do it, but I’m not going to upgrade to a full, paid security suite for a virtual machine I fire up only if and when I have to (which isn’t that often) – it’s a no-sale. So I did a bit of googling and found the solution.

The trick is that you need to modify the following registry keys and flip them from 1 to 0:

However, the problem with doing so is that Zone Alarm has these keys locked, and quiting ZoneAlarm doesn’t unlock them, so you need to reboot Windows into Safe Mode to do it by stabbing F8 during boot a few times and then selecting to boot in Safe Mode.

Once you’re in Safe Mode, you can either go and flip the flags manually using regedit, or you could dump the following into a file with a .reg extension and then execute it:

Or, you could download and run a version I created earlier (Right click and Save As…): ZA-NoNag.reg

Done & done.

Credits: Many thanks to oldsod on the ZA forums for the fix!