Configuring fail2ban With SquirrelMail On CentOS 5.3/ISPConfig 3
|
Submitted by gscott187 (Contact Author) (Forums) on Tue, 2009-08-11 11:32. :: CentOS | Email | Security
Configuring fail2ban With SquirrelMail On CentOS 5.3/ISPConfig 3IntroductionThis tutorial shows how you can prevent unlimited login attempts and hence brute force attacks against your SquirrelMail Web login by using fail2ban.
1. RequirementsEnsure that both fail2ban and SquirrelMail are installed on a CentOS v5.3/ISPConfig 3 machine detailed here. However, their installation is straight forward: yum install fail2ban squirrelmail You must be actively using iptables as your firewall. Fail2ban works by creating a temporary drop rule for the unauthorised source IP address.
2. SquirrelMail logging configurationSquirrelMail (imapd) under CentOS v5.3/ISPConfig 3 by default logs to /var/log/maillog but only as IP address 127.0.0.1 (localhost). Since we are trying to ban a specific source address, fail2ban cannot use this file. Therefore, we install and use Squirrel Logger to capture the real source address of the login attempt. Download and install Squirrel Logger: cd /usr/share/squirrelmail/plugins Whilst this plugin was the latest version of Squirrel Logger, if there has been a revision upgrade then download it directly from the SquirrelMail Plugins site here. If your machine uses a local time that is not GMT, use vi to change: $sl_use_GMT = 1 to $sl_use_GMT = 0 in config.php: Original config.php: ... // Log dates in GMT? If you do not do this, dates will // be logged in whatever timezone each user is in (or // has set in their personal preferences) // // 1 = yes // 0 = no // $sl_use_GMT = 1; ... Modified config.php: ... // Log dates in GMT? If you do not do this, dates will // be logged in whatever timezone each user is in (or // has set in their personal preferences) // // 1 = yes // 0 = no // $sl_use_GMT = 0; ... Delete the downloaded Squirrel Logger gzip file: cd /usr/share/squirrelmail/plugins Configure SquirrelMail to use the Squirrel Logger plugin: /usr/share/squirrelmail/config/conf.pl SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- Main Menu -- 1. Organization Preferences 2. Server Settings 3. Folder Defaults 4. General Options 5. Themes 6. Address Books 7. Message of the Day (MOTD) 8. Plugins 9. Database 10. Languages D. Set pre-defined settings for specific IMAP servers C Turn color on S Save data Q Quit Command >> Select: Plugins SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
Select: squirrel_logger SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Plugins
Installed Plugins
1. delete_move_next
2. squirrelspell
3. newmail
4. squirrel_logger
Select: Save data, Quit
3. Fail2ban configurationChange to the fail2ban configuration directory: cd /etc/fail2ban On the assumption that you are using http transport for SquirrelMail, use vi to add the following lines to the jail.conf file: [squirrelmail-iptables]
enabled = true
filter = squirrelmail
action = iptables[name=SquirrelMail, port=http, protocol=tcp]
sendmail-whois[name=SquirrelMail, dest=you@your_domain.com, sender=fail2ban@your_domain.com]
logpath = /var/lib/squirrelmail/prefs/squirrelmail_access_log
maxretry = 4
Ensure that maxretry and email addresses for dest and sender are set to your requirements. Change to fail2ban filter directory: cd filter.d In the filter.d directory, use vi to create a squirrelmail.conf file with the following contents: # Fail2Ban configuration file # # Author: Bill Landry ((email_protected)) # # $Revision: 510 $ [Definition] # Option: failregex # Notes.: regex to match the password failures messages in the logfile. The # host must be matched by a group named "host". The tag " Fail2ban needs to recognise the date format used in the squirrelmail_access_log file. cd /usr/share/fail2ban/server Use vi, to edit the datedetector.py file and add the following lines between the Apache format and Exim format sections: # SquirrelMail 09/13/2007 06:43:20
template = DateStrptime()
template.setName("Month/Day/Year Hour:Minute:Second")
template.setRegex("\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2}")
template.setPattern("%m/%d/%Y %H:%M:%S")
self.__templates.append(template)
|



Recent comments
1 day 4 hours ago
1 day 7 hours ago
1 day 8 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 13 hours ago
1 day 14 hours ago
2 days 6 hours ago
2 days 7 hours ago
2 days 11 hours ago