diff --git a/ChangeLog b/ChangeLog index bc849aaa..de3de7f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,8 +32,14 @@ ver. 0.9.3 (2015/XX/XXX) - wanna-be-released currently not banned or persistent) - New Features: + * RETURN iptables target is now a variable: + * New type of operation: pass2allow, use fail2ban for "knocking", + opening a closed port by swapping blocktype and returntype * New filters: - froxlor-auth Thanks Joern Muehlencord + - apache-pass - filter Apache access log for successfull authentication + * New jails: + - pass2allow-ftp - allows FTP traffic after successful HTTP authentication - Enhancements: * action.d/cloudflare.conf - improved documentation on how to allow diff --git a/config/action.d/iptables-allports.conf b/config/action.d/iptables-allports.conf index b30404d3..9e2d18a3 100644 --- a/config/action.d/iptables-allports.conf +++ b/config/action.d/iptables-allports.conf @@ -18,7 +18,7 @@ before = iptables-common.conf # Values: CMD # actionstart = iptables -N f2b- - iptables -A f2b- -j RETURN + iptables -A f2b- -j iptables -I -p -j f2b- # Option: actionstop diff --git a/config/action.d/iptables-common.conf b/config/action.d/iptables-common.conf index c191c5a1..dff01362 100644 --- a/config/action.d/iptables-common.conf +++ b/config/action.d/iptables-common.conf @@ -43,3 +43,9 @@ protocol = tcp # REJECT, REJECT --reject-with icmp-port-unreachable # Values: STRING blocktype = REJECT --reject-with icmp-port-unreachable + +# Option: returntype +# Note: This is the default rule on "actionstart". This should be RETURN +# in all (blocking) actions, except REJECT in allowing actions. +# Values: STRING +returntype = RETURN diff --git a/config/action.d/iptables-multiport-log.conf b/config/action.d/iptables-multiport-log.conf index f4d80d6c..093ce7b2 100644 --- a/config/action.d/iptables-multiport-log.conf +++ b/config/action.d/iptables-multiport-log.conf @@ -20,7 +20,7 @@ before = iptables-common.conf # Values: CMD # actionstart = iptables -N f2b- - iptables -A f2b- -j RETURN + iptables -A f2b- -j iptables -I 1 -p -m multiport --dports -j f2b- iptables -N f2b--log iptables -I f2b--log -j LOG --log-prefix "$(expr f2b- : '\(.\{1,23\}\)'):DROP " --log-level warning -m limit --limit 6/m --limit-burst 2 diff --git a/config/action.d/iptables-multiport.conf b/config/action.d/iptables-multiport.conf index b70baf92..f365d917 100644 --- a/config/action.d/iptables-multiport.conf +++ b/config/action.d/iptables-multiport.conf @@ -15,7 +15,7 @@ before = iptables-common.conf # Values: CMD # actionstart = iptables -N f2b- - iptables -A f2b- -j RETURN + iptables -A f2b- -j iptables -I -p -m multiport --dports -j f2b- # Option: actionstop diff --git a/config/action.d/iptables-new.conf b/config/action.d/iptables-new.conf index 3c6657d9..831931dd 100644 --- a/config/action.d/iptables-new.conf +++ b/config/action.d/iptables-new.conf @@ -17,7 +17,7 @@ before = iptables-common.conf # Values: CMD # actionstart = iptables -N f2b- - iptables -A f2b- -j RETURN + iptables -A f2b- -j iptables -I -m state --state NEW -p --dport -j f2b- # Option: actionstop diff --git a/config/action.d/iptables.conf b/config/action.d/iptables.conf index a956fc55..572bdc11 100644 --- a/config/action.d/iptables.conf +++ b/config/action.d/iptables.conf @@ -15,7 +15,7 @@ before = iptables-common.conf # Values: CMD # actionstart = iptables -N f2b- - iptables -A f2b- -j RETURN + iptables -A f2b- -j iptables -I -p --dport -j f2b- # Option: actionstop diff --git a/config/filter.d/apache-pass.conf b/config/filter.d/apache-pass.conf new file mode 100644 index 00000000..dd00f953 --- /dev/null +++ b/config/filter.d/apache-pass.conf @@ -0,0 +1,20 @@ +# Fail2Ban Apache pass filter +# This filter is for access.log, NOT for error.log +# +# The knocking request must have a referer. + +[INCLUDES] + +before = apache-common.conf + +[Definition] + +failregex = ^ - \w+ \[\] "GET HTTP/1\.[01]" 200 \d+ ".*" "[^-].*"$ + +ignoreregex = + +[Init] + +knocking_url = /knocking/ + +# Author: Viktor Szépe diff --git a/config/jail.conf b/config/jail.conf index 67eda24e..b0ed6355 100644 --- a/config/jail.conf +++ b/config/jail.conf @@ -767,3 +767,16 @@ port = 2222 enabled = false logpath = /var/lib/portsentry/portsentry.history maxretry = 1 + +[pass2allow-ftp] +# this pass2allow example allows FTP traffic after successful HTTP authentication +port = ftp,ftp-data,ftps,ftps-data +# knocking URL needs to be customized in apache-pass.local +filter = apache-pass +# access log of the website with HTTP auth +logpath = %(apache_access_log)s +blocktype = RETURN +returntype = DROP +bantime = 3600 +maxretry = 1 +findtime = 1 diff --git a/fail2ban/tests/files/logs/apache-pass b/fail2ban/tests/files/logs/apache-pass new file mode 100644 index 00000000..cb8d3454 --- /dev/null +++ b/fail2ban/tests/files/logs/apache-pass @@ -0,0 +1,2 @@ +# failJSON: { "time": "2013-06-27T11:55:44", "match": true , "host": "192.0.2.12" } +192.0.2.12 - user1 [27/Jun/2013:11:55:44] "GET /knocking/ HTTP/1.1" 200 266 "http://domain.net/hello-world/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:40.0) Gecko/20100101 Firefox/40.0"