diff --git a/ChangeLog b/ChangeLog index f55b4873..0e433e90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,7 +55,11 @@ configuration before relying on it. * Added action xarf-login-attack to report formatted attack messages according to the XARF standard (v0.2). Close gh-105 * Support PyPy + * Add filter for apache-botsearch * Filter for stunnel + * Filter for Counter Strike 1.6. Thanks to onorua for logs. + Close gh-347 + * Filter for squirrelmail. Close gh-261 - Enhancements * Jail names increased to 26 characters and iptables prefix reduced @@ -64,9 +68,11 @@ configuration before relying on it. * Multiline regex for Disconnecting: Too many authentication failures for root [preauth]\nConnection closed by 6X.XXX.XXX.XXX [preauth] * Replacing use of deprecated API (.warning, .assertEqual, etc) - * [..a648cc2] Filters can have options now too + * [..a648cc2] Filters can have options now too which are substituted into + failregex / ignoreregex * [..e019ab7] Multiple instances of the same action are allowed in the same jail -- use actname option to disambiguate. + * Add honeypot email address to exim-spam filter as argument ver. 0.8.12 (2013/12/XX) - things-can-only-get-better ----------- @@ -91,7 +97,9 @@ ver. 0.8.12 (2013/12/XX) - things-can-only-get-better - Fix apache-common for apache-2.4 log file format. Thanks Mark White. Closes gh-516 - Asynchat changed to use push method which verifys whether all data was - send. This ensures that all data is sent before closing the connection. + send. This ensures that all data is sent before closing the connection. + - Removed unnecessary reference to as yet undeclared $jail_name when checking + a specific jail in nagios script. - Enhancements: - added firewallcmd-ipset action @@ -107,15 +115,27 @@ ver. 0.8.12 (2013/12/XX) - things-can-only-get-better - exim-spam filter to match spamassassin log entry for option SAdevnull. Thanks Ivo Truxa. Closes gh-533 - filter.d/nsd.conf -- also amended Unix date template to match nsd format + - Added to sshd filter expression for "Received disconnect from : 3: + ...: Auth fail". Thanks Marcel Dopita. Closes gh-289 - loglines now also report "[PID]" after the name portion + - Added filter.d/ejabberd-auth + - Improved ACL-handling for Asterisk + - loglines now also report "[PID]" after the name portion + - Added improper command pipelining to postfix filter. - New Features: - - Added filter for solid-pop3d -- thanks to Jacques Lav!gnotte on mailinglist. - - Added filter for apache-modsecurity - - Added filter for openwebmail thanks Ivo Truxa. Closes gh-543 + - filter.d/solid-pop3d -- added thanks to Jacques Lav!gnotte on mailinglist. + - Add filter for apache-modsecurity + - filter.d/nsd.conf -- also amended Unix date template to match nsd format + - Added openwebmail filter thanks Ivo Truxa. Closes gh-543 + - Added filter for freeswitch. Thanks Jim and editors and authors of + http://wiki.freeswitch.org/wiki/Fail2ban + - Added groupoffice filter thanks to logs from Merijn Schering. + Closes gh-566 - Added filter for horde + ver. 0.8.11 (2013/11/13) - loves-unittests-and-tight-DoS-free-filter-regexes In light of CVE-2013-2178 that triggered our last release we have put diff --git a/MANIFEST b/MANIFEST index 4232b287..a2103e59 100644 --- a/MANIFEST +++ b/MANIFEST @@ -86,6 +86,7 @@ fail2ban/tests/files/config/apache-auth/README fail2ban/tests/files/config/apache-auth/noentry/.htaccess fail2ban/tests/files/database_v1.db fail2ban/tests/files/ignorecommand.py +fail2ban/tests/files/filter.d/substition.conf fail2ban/tests/files/filter.d/testcase-common.conf fail2ban/tests/files/filter.d/testcase01.conf fail2ban/tests/files/testcase01.log @@ -101,12 +102,14 @@ fail2ban/tests/files/logs/bsd/syslog-vv.txt fail2ban/tests/files/logs/3proxy fail2ban/tests/files/logs/apache-auth fail2ban/tests/files/logs/apache-badbots +fail2ban/tests/files/logs/apache-botscripts fail2ban/tests/files/logs/apache-modsecurity fail2ban/tests/files/logs/apache-nohome fail2ban/tests/files/logs/apache-noscript fail2ban/tests/files/logs/apache-overflows fail2ban/tests/files/logs/assp fail2ban/tests/files/logs/asterisk +fail2ban/tests/files/logs/counter-strike fail2ban/tests/files/logs/courier-auth fail2ban/tests/files/logs/courier-smtp fail2ban/tests/files/logs/cyrus-imap @@ -115,6 +118,8 @@ fail2ban/tests/files/logs/dropbear fail2ban/tests/files/logs/ejabberd-auth fail2ban/tests/files/logs/exim fail2ban/tests/files/logs/exim-spam +fail2ban/tests/files/logs/freeswitch +fail2ban/tests/files/logs/groupoffice fail2ban/tests/files/logs/gssftpd fail2ban/tests/files/logs/guacamole fail2ban/tests/files/logs/kerio @@ -167,10 +172,12 @@ config/fail2ban.conf config/filter.d/common.conf config/filter.d/apache-auth.conf config/filter.d/apache-badbots.conf +config/filter.d/apache-botsearch.conf config/filter.d/apache-nohome.conf config/filter.d/apache-noscript.conf config/filter.d/apache-overflows.conf config/filter.d/nginx-http-auth.conf +config/filter.d/counter-strike.conf config/filter.d/courier-auth.conf config/filter.d/courier-smtp.conf config/filter.d/cyrus-imap.conf @@ -214,6 +221,8 @@ config/filter.d/3proxy.conf config/filter.d/apache-common.conf config/filter.d/exim-common.conf config/filter.d/exim-spam.conf +config/filter.d/freeswitch.conf +config/filter.d/groupoffice.conf config/filter.d/perdition.conf config/filter.d/uwimap-auth.conf config/filter.d/courier-auth.conf diff --git a/THANKS b/THANKS index 23870ca9..3bd2e411 100644 --- a/THANKS +++ b/THANKS @@ -62,9 +62,11 @@ Markus Hoffmann Marvin Rouge mEDI Мернов Георгий +Merijn Schering Michael C. Haller Michael Hanselmann Nick Munger +onorua Patrick Börjesson Raphaël Marichez RealRancor @@ -81,6 +83,7 @@ Stephen Gildea Steven Hiscocks TESTOVIK Tom Pike +Tomas Pihl Tyler Vaclav Misek Vincent Deffontaines diff --git a/bin/fail2ban-regex b/bin/fail2ban-regex index 014bfb2f..d470be9c 100755 --- a/bin/fail2ban-regex +++ b/bin/fail2ban-regex @@ -41,7 +41,7 @@ except ImportError: journal = None from fail2ban.version import version -from fail2ban.client.configparserinc import SafeConfigParserWithIncludes +from fail2ban.client.filterreader import FilterReader from fail2ban.server.filter import Filter from fail2ban.server.failregex import RegexException @@ -206,8 +206,6 @@ class LineStats(object): class Fail2banRegex(object): - CONFIG_DEFAULTS = {'configpath' : "/etc/fail2ban/"} - def __init__(self, opts): self._verbose = opts.verbose self._debuggex = opts.debuggex @@ -257,44 +255,34 @@ class Fail2banRegex(object): assert(regextype in ('fail', 'ignore')) regex = regextype + 'regex' if os.path.isfile(value): - reader = SafeConfigParserWithIncludes(defaults=self.CONFIG_DEFAULTS) - try: - reader.read(value) - print "Use %11s file : %s" % (regex, value) - # TODO: reuse functionality in client - regex_values = [ - RegexStat(m) - for m in reader.get("Definition", regex).split('\n') - if m != ""] - except NoSectionError: - print "No [Definition] section in %s" % value - return False - except NoOptionError: - print "No %s option in %s" % (regex, value) - return False - except MissingSectionHeaderError: - print "No section headers in %s" % value - return False + print "Use %11s file : %s" % (regex, value) + reader = FilterReader(value, 'fail2ban-regex-jail', {}) + reader.setBaseDir(None) - # Read out and set possible value of maxlines - try: - maxlines = reader.get("Init", "maxlines") - except (NoSectionError, NoOptionError): - # No [Init].maxlines found. - pass - else: - try: - self.setMaxLines(maxlines) - except ValueError: - print "ERROR: Invalid value for maxlines (%(maxlines)r) " \ - "read from %(value)s" % locals() - return False - # Read out and set possible value for journalmatch - try: - journalmatch = reader.get("Init", "journalmatch") - except (NoSectionError, NoOptionError): - # No [Init].journalmatch found. - pass + if reader.readexplicit(): + reader.getOptions(None) + readercommands = reader.convert() + regex_values = [ + RegexStat(m[3]) + for m in filter( + lambda x: x[0] == 'set' and x[2] == "add%sregex" % regextype, + readercommands)] + # Read out and set possible value of maxlines + for command in readercommands: + if command[2] == "maxlines": + maxlines = int(command[3]) + try: + self.setMaxLines(maxlines) + except ValueError: + print "ERROR: Invalid value for maxlines (%(maxlines)r) " \ + "read from %(value)s" % locals() + return False + elif command[2] == 'addjournalmatch': + journalmatch = command[3] + self.setJournalMatch(shlex.split(journalmatch)) + elif command[2] == 'datepattern': + datepattern = command[3] + self.setDatePattern(datepattern) else: self.setJournalMatch(shlex.split(journalmatch)) # Read out and set possible value for journalmatch diff --git a/config/action.d/apf.conf b/config/action.d/apf.conf index f1d54dd2..5c4a2614 100644 --- a/config/action.d/apf.conf +++ b/config/action.d/apf.conf @@ -1,45 +1,17 @@ # Fail2Ban configuration file +# https://www.rfxn.com/projects/advanced-policy-firewall/ # -# Author: Mark McKinstry +# Note: APF doesn't play nicely with other actions. It has been observed to +# remove bans created by other iptables based actions. If you are going to use +# this action, use it for all of your jails. # +# DON'T MIX APF and other IPTABLES based actions [Definition] -# Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. -# Values: CMD -# actionstart = - -# Option: actionstop -# Notes.: command executed once at the end of Fail2Ban -# Values: CMD -# actionstop = - -# Option: actioncheck -# Notes.: command executed once before each actionban command -# Values: CMD -# actioncheck = - -# Option: actionban -# Notes.: command executed when banning an IP. Take care that the -# command is executed with Fail2Ban user rights. -# Tags: IP address -# number of failures -#