As the Wiki for fail2ban is a little less than explanatory than it could be (and they reversed my edits which made the instructions clearer), here are my own notes on setting up fail2ban to block pop3 attacks.
Have been seeing sample dictionary attacks on some servers for a while now from random ip addresses – eg
Sep 28 13:01:03 www vpopmail[20410]: vchkpw-pop3: vpopmail user not found www@:24.153.205.71 Sep 28 13:01:03 www vpopmail[20411]: vchkpw-pop3: vpopmail user not found web@:24.153.205.71 Sep 28 13:01:09 www vpopmail[20417]: vchkpw-pop3: vpopmail user not found web@:24.153.205.71 Sep 28 13:01:11 www vpopmail[20420]: vchkpw-pop3: vpopmail user not found web@:24.153.205.71
Annoying, but not realistically going to provide much of a security issue – most of the user names are the generic ones which aren’t actually in use on the servers.
As we already use fail2ban to perform basic service blocks against naughty script kiddie wannabee’s, why not have it block vpopmail attacks also.
Our mail error logs are located in /var/log/mail.log
As you saw above, the logs show the same common text for each failed login –
vchkpw-pop3: vpopmail user not found web@:24.153.205.71
A simple regex to identify that in the logs would look like this (as per the fail2ban wiki)
failregex = vchkpw-pop3: vpopmail user not found .*@:<HOST>$
First step is to create a filter for fail2ban.
Create /etc/fail2ban/filter.d/vpopmail.conf as below:
# Fail2Ban configuration file for vpopmail # # Author: Lawrence Sheed # # $Revision: 1.0 $ # [Definition] # Option: failregex # Notes.: regex to match the password failures messages in the logfile. # Values: TEXT # failregex = vchkpw-pop3: vpopmail user not found .*@:<HOST>$ # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =
Second step is to add our filter to the fail2ban setup
Add this to the bottom of /etc/fail2ban/jail.conf
[vpopmail] enabled = true port = pop3 filter = vpopmail logpath = /var/log/mail.log maxretry = 3
logpath should be amended to whatever your mail logs for vpopmail appear.
maxretry should be set to a value that you agree with.
Restart fail2ban with a: /etc/init.d/fail2ban restart
and check that it has added the filter.
tail /var/log/fail2ban.log
You should see a line like this:
2009-10-01 12:36:09,590 fail2ban.jail : INFO Jail 'vpopmail' started
If so, you’re all set!
Some additional tips, as I have found some issues subsequently in Fail2ban on some systems:
If you find that fail2ban gives error 200 or 400 on occasion, this is due to a timing issue bug in fail2ban.
There are 2 possible solutions:
Solution 1 – Edit fail2ban
Open /usr/bin/fail2ban-client
Look for
def __processCmd(self, cmd, showRet = True): beautifier = Beautifier() for c in cmd:
After for c in cmd: add a delay
time.sleep(0.5)
This should look similar to this now –
def __processCmd(self, cmd, showRet = True): beautifier = Beautifier() for c in cmd: time.sleep(0.5)
Save, and restart fail2ban. If you still see 200 or 400 issues, increase the delay higher e.g. time.sleep(0.8)
Solution 2 – Use a different block method
Instead of iptables, we can configure fail2ban to use route
Add a config file for this:
pico /etc/fail2ban/action.d/route.conf
Add this into the file and save it.
# Fail2Ban configuration file [Definition] actionban = ip route add unreachable <ip> actionunban = ip route del unreachable <ip>
Open /etc/fail2ban/jail.conf
Look for ban action = … in the [DEFAULT] section, and comment it out with a # at the start of the line
then add
eg
#banaction = iptables banaction = route
Save the file.
Restart fail2ban
It will now use route to block bad ip’s.
Archives
- December 2011
- November 2011
- October 2011
- September 2011
- July 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
Categories
- Apple
- Badges
- BMW
- China Related
- Cool Hunting
- Exploits
- Firmware
- Food
- General Talk
- government
- IP Cam
- iPhone
- Lasers
- legislation
- MODx
- MySQL
- requirements
- Service Issues
- Tao Bao
- Technical Mumbo Jumbo
- Things that will get me censored
- Travel
- Uncategorized
- Useful Info
Most Popular Posts
- Samsung N310 (Samsung Go) Hackintosh Installation on Snow Leopard (9997)
- BMW Keys and Transponders E36 E38 E46 etc (EWS2) (7418)
- eFrontWPI - Wordpress integration Plugin for eFront (7308)
- IPCam Hacking - pt#2 (6757)
- IP Cam Hacking – pt#5 (4684)
Tags
Recent Comments
-
tryphon: It helped me to fix mine. I used a pair of pliers like you did and it worked fine. I drink a coffee typing...
-
mark: I have a ms10105 v4.1 moshisoft board and here is the pinout: 1 y stepper a (yellow) 2 y stepper a (white) 3...
-
Lawrence Sheed: Haven’t taken a deep look yet, probably next month can check it out. There are people who are...
-
mark: Yes…that moshi software is crap. I used the corel draw plugin for awhile but it only works about 20% of...
-
Kunlun: I tried to get my motorbike lesson after my car driving lesson, they answered me that I needed to wait 1...
Recent Trackbacks
- SISTEMAS O.R.P: Recuperar una cámara Zaapa CIP-RW después de un fallo de actualización
- Blog - DO Bots: Brookstone Rover AC13
- How can I stop Pop3 Brute Force attacks: need to create a regex, and add it to fail2ban Here is a guide....
- shanghailoz is our latest member! -:
- Probleem bij installatie op Samsung N310:



ICP Permit
Webmail
Newsletters
Support