From e2faa312c1735b9ba335f5c5b82ddf556a87fd71 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 20 Nov 2013 09:52:14 +1100 Subject: [PATCH 01/24] TST: test case for horde --- testcases/files/logs/horde | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 testcases/files/logs/horde diff --git a/testcases/files/logs/horde b/testcases/files/logs/horde new file mode 100644 index 00000000..55f2a6af --- /dev/null +++ b/testcases/files/logs/horde @@ -0,0 +1,2 @@ +Nov 11 18:57:57 HORDE [error] [horde] FAILED LOGIN for graham [203.16.208.190] to Horde [on line 116 of "/home/ace-hosting/public_html/horde/login.php"] + From 83f3aeb308253f9fba22001db71860461753f541 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 2 Jan 2014 23:12:36 +1100 Subject: [PATCH 02/24] ENH: filter for horde --- ChangeLog | 1 + config/filter.d/horde.conf | 16 ++++++++++++++++ testcases/files/logs/horde | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 config/filter.d/horde.conf diff --git a/ChangeLog b/ChangeLog index c092037a..edf4591c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ ver. 0.8.12 (2013/12/XX) - things-can-only-get-better - Add filter for apache-modsecurity - filter.d/nsd.conf -- also amended Unix date template to match nsd format - Added filter.d/openwebmail filter thanks Ivo Truxa. Closes gh-543 + - Added filter.d/horde - Enhancements: - loglines now also report "[PID]" after the name portion diff --git a/config/filter.d/horde.conf b/config/filter.d/horde.conf new file mode 100644 index 00000000..b94ebf64 --- /dev/null +++ b/config/filter.d/horde.conf @@ -0,0 +1,16 @@ +# fail2ban filter configuration for horde + + +[Definition] + + +failregex = ^ HORDE \[error\] \[(horde|imp)\] FAILED LOGIN for \S+ \[\](\(forwarded for \[\S+\]\))? to (Horde|{[^}]+}) \[(pid \d+ )?on line \d+ of \S+\]$ + + +ignoreregex = + +# DEV NOTES: +# https://github.com/horde/horde/blob/master/imp/lib/Auth.php#L132 +# https://github.com/horde/horde/blob/master/horde/login.php +# +# Author: Daniel Black diff --git a/testcases/files/logs/horde b/testcases/files/logs/horde index 55f2a6af..135deee3 100644 --- a/testcases/files/logs/horde +++ b/testcases/files/logs/horde @@ -1,2 +1,6 @@ +# failJSON: { "time": "2004-11-11T18:57:57", "match": true , "host": "203.16.208.190" } Nov 11 18:57:57 HORDE [error] [horde] FAILED LOGIN for graham [203.16.208.190] to Horde [on line 116 of "/home/ace-hosting/public_html/horde/login.php"] +# failJSON: { "time": "2004-12-15T08:59:59", "match": true , "host": "1.2.3.4" } +Dec 15 08:59:59 HORDE [error] [imp] FAILED LOGIN for emai.user@somedomain.com [1.2.3.4] to {mx.somedomain.com:993 [imap/ssl/novalidate-cert]} [pid 68394 on line 139 of /usr/local/www/www.somedomain.com/public_html/horde/imp/lib/Auth/imp.php"] + From 04d28fd2e1bb2be5ac82555fb8898fb5239ca658 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 3 Jan 2014 13:00:37 +1100 Subject: [PATCH 03/24] ENH: add filter freeswitch - as raised on mailing list --- ChangeLog | 2 ++ config/filter.d/freeswitch.conf | 14 ++++++++++++++ config/jail.conf | 12 ++++++++++++ testcases/files/logs/freeswitch | 2 ++ 4 files changed, 30 insertions(+) create mode 100644 config/filter.d/freeswitch.conf create mode 100644 testcases/files/logs/freeswitch diff --git a/ChangeLog b/ChangeLog index c092037a..d4dae353 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,8 @@ ver. 0.8.12 (2013/12/XX) - things-can-only-get-better - Add filter for apache-modsecurity - filter.d/nsd.conf -- also amended Unix date template to match nsd format - Added filter.d/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 - Enhancements: - loglines now also report "[PID]" after the name portion diff --git a/config/filter.d/freeswitch.conf b/config/filter.d/freeswitch.conf new file mode 100644 index 00000000..3835c5ad --- /dev/null +++ b/config/filter.d/freeswitch.conf @@ -0,0 +1,14 @@ +# Fail2Ban configuration file +# +# In freeswitch configuration: +# + +[Definition] + +failregex = ^\.\d+ \[WARNING\] sofia_reg.c:\d+ SIP auth (failure|challenge) \((REGISTER|INVITE)\) on sofia profile \'[^']+\' for \[.*\] from ip + +ignoreregex = + +# Author: Rupa SChomaker, soapee01, Daniel Black +# http://wiki.freeswitch.org/wiki/Fail2ban +# diff --git a/config/jail.conf b/config/jail.conf index e9441416..3f660d2c 100644 --- a/config/jail.conf +++ b/config/jail.conf @@ -382,6 +382,18 @@ action = iptables-multiport[name=asterisk-tcp, port="5060,5061", protocol=tcp] logpath = /var/log/asterisk/messages maxretry = 10 + +[freeswitch] + +enabled = false +port = 5060,5061,5080,5081 +filter = freeswitch +logpath = /var/log/freeswitch.log +maxretry = 10 +action = iptables-multiport[name=freeswitch-tcp, port="5060,5061,5080,5081", protocol=tcp] + iptables-multiport[name=freeswitch-udp, port="5060,5061,5080,5081", protocol=udp] + + # Historical support (before https://github.com/fail2ban/fail2ban/issues/37 was fixed ) # use [asterisk] for new jails [asterisk-tcp] diff --git a/testcases/files/logs/freeswitch b/testcases/files/logs/freeswitch new file mode 100644 index 00000000..96e2b1cf --- /dev/null +++ b/testcases/files/logs/freeswitch @@ -0,0 +1,2 @@ +# failJSON: { "time": "2013-12-31T17:39:54", "match": true, "host": "81.94.202.251" } +2013-12-31 17:39:54.767815 [WARNING] sofia_reg.c:1533 SIP auth challenge (INVITE) on sofia profile 'internal' for [011448708752617@192.168.2.51] from ip 81.94.202.251 From a0c2de3e4db65f429382e8ccaed66cb0f0ca88e6 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 3 Jan 2014 16:51:38 +1100 Subject: [PATCH 04/24] DOC: document incompatiblity between APF and iptables-* actions. Closes gh-510 --- config/action.d/apf.conf | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/config/action.d/apf.conf b/config/action.d/apf.conf index f1d54dd2..f0dde977 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 -#