Skip to content

Commit ca7d370

Browse files
committed
chore(confs): sync filter.d with upstream Fail2Ban
1 parent 452053c commit ca7d370

34 files changed

+342
-153
lines changed

filter.d/apache-auth.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2023/11/18
22
# Fail2Ban apache-auth filter
33
#
44

@@ -65,7 +65,7 @@ ignoreregex =
6565
# ^user .*: one-time-nonce mismatch - sending new nonce\s*$
6666
# ^realm mismatch - got `(?:[^']*|.*?)' but no realm specified\s*$
6767
#
68-
# Because url/referer are foreign input, short form of regex used if long enough to idetify failure.
68+
# Because url/referer are foreign input, short form of regex used if long enough to identify failure.
6969
#
7070
# Author: Cyril Jaquier
7171
# Major edits by Daniel Black and Ben Rubson.

filter.d/apache-common.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2024/03/15
22
# Generic configuration items (to be used as interpolations) in other
33
# apache filters.
44

@@ -30,7 +30,7 @@ apache-prefix = <apache-prefix-<logging>>
3030

3131
apache-pref-ignore =
3232

33-
_apache_error_client = <apache-prefix>\[(:?error|<apache-pref-ignore>\S+:\S+)\]( \[pid \d+(:\S+ \d+)?\])? \[client <HOST>(:\d{1,5})?\]
33+
_apache_error_client = <apache-prefix>\[(:?error|<apache-pref-ignore>\S+:\S+)\]( \[pid \d+(:\S+ \d+)?\])? \[(?:client|remote) <HOST>(:\d{1,5})?\]
3434

3535
datepattern = {^LN-BEG}
3636

filter.d/apache-noscript.conf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2025/03/28
22
# Fail2Ban filter to block web requests for scripts (on non scripted websites)
33
#
44
# This matches many types of scripts that don't exist. This could generate a
@@ -20,11 +20,10 @@ before = apache-common.conf
2020

2121
script = /\S*(?:php(?:[45]|[.-]cgi)?|\.asp|\.exe|\.pl|\bcgi-bin/)
2222

23-
prefregex = ^%(_apache_error_client)s (?:AH0(?:01(?:28|30)|1(?:264|071)|2811): )?(?:(?:[Ff]ile|script|[Gg]ot) )<F-CONTENT>.+</F-CONTENT>$
23+
prefregex = ^%(_apache_error_client)s (?:AH0(?:01(?:28|30)|1(?:264|071)|2811): )?(?=(?:[Ff]ile|[Ss]cript|[Gg]ot error|stderr from) )<F-CONTENT>.+</F-CONTENT>$
2424

25-
failregex = ^(?:does not exist|not found or unable to stat): <script>\b
26-
^'<script>\S*' not found or unable to stat
27-
^error '[Pp]rimary script unknown(?:\\n)?'
25+
failregex = ^(?:(?:[Ff]ile does not exist|[Ss]cript not found or unable to stat): <script>\b|[Gg]ot error '[Pp]rimary script unknown\b)
26+
^(?:stderr from |script (?P<_q>'))<script>\S*(?(_q)'|) (?:script )?(?:does not exist|not found or unable to stat)
2827

2928
ignoreregex =
3029

filter.d/apache-overflows.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2024/06/28
22
# Fail2Ban filter to block web requests on a long or suspicious nature
33
#
44

@@ -9,7 +9,7 @@ before = apache-common.conf
99

1010
[Definition]
1111

12-
failregex = ^%(_apache_error_client)s (?:(?:AH001[23][456]: )?Invalid (method|URI) in request\b|(?:AH00565: )?request failed: URI too long \(longer than \d+\)|request failed: erroneous characters after protocol string:|(?:AH00566: )?request failed: invalid characters in URI\b)
12+
failregex = ^%(_apache_error_client)s (?:(?:AH(?:001[23][456]|10244): )?[Ii]nvalid (method|URI)\b|(?:AH00565: )?request failed: URI too long \(longer than \d+\)|request failed: erroneous characters after protocol string:|(?:AH00566: )?request failed: invalid characters in URI\b)
1313

1414
ignoreregex =
1515

filter.d/asterisk.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2025/07/20
22
# Fail2Ban filter for asterisk authentication failures
33
#
44

@@ -22,13 +22,13 @@ log_prefix= (?:NOTICE|SECURITY|WARNING)%(__pid_re)s:?(?:\[C-[\da-f]*\])?:? [^:]+
2222
prefregex = ^%(__prefix_line)s%(log_prefix)s <F-CONTENT>.+</F-CONTENT>$
2323

2424
failregex = ^Registration from '[^']*' failed for '<HOST>(:\d+)?' - (?:Wrong password|Username/auth name mismatch|No matching peer found|Not a local domain|Device does not match ACL|Peer is not supposed to register|ACL error \(permit/deny\)|Not a local domain)$
25-
^Call from '[^']*' \((?:(?:TCP|UDP):)?<HOST>:\d+\) to extension '[^']*' rejected because extension not found in context
25+
^Call (?:from '[^']*' )?\((?:(?:TCP|UDP):)?<HOST>:\d+\) to extension '[^']*' rejected because extension not found in context
2626
^(?:Host )?<HOST> (?:failed (?:to authenticate\b|MD5 authentication\b)|tried to authenticate with nonexistent user\b)
2727
^No registration for peer '[^']*' \(from <HOST>\)$
2828
^hacking attempt detected '<HOST>'$
2929
^SecurityEvent="(?:FailedACL|InvalidAccountID|ChallengeResponseFailed|InvalidPassword)"(?:(?:,(?!RemoteAddress=)\w+="[^"]*")*|.*?),RemoteAddress="IPV[46]/[^/"]+/<HOST>/\d+"(?:,(?!RemoteAddress=)\w+="[^"]*")*$
3030
^"Rejecting unknown SIP connection from <HOST>(?::\d+)?"$
31-
^Request (?:'[^']*' )?from '(?:[^']*|.*?)' failed for '<HOST>(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\s*$
31+
^Request (?:'[^']*' )?from '(?:[^']*|.*?)' failed for '<HOST>(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\b[^']*$
3232

3333
# FreePBX (todo: make optional in v.0.10):
3434
# ^(%(__prefix_line)s|\[\]\s*WARNING%(__pid_re)s:?(?:\[C-[\da-f]*\])? )[^:]+: Friendly Scanner from <HOST>$

filter.d/dante.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/12/15
1+
## Version 2023/12/30
22
# Fail2Ban filter for dante
33
#
44
# Make sure you have "log: error" set in your "client pass" directive
@@ -10,7 +10,7 @@ before = common.conf
1010
[Definition]
1111
_daemon = danted
1212

13-
failregex = ^%(__prefix_line)sinfo: block\(1\): tcp/accept \]: <HOST>\.\d+ [\d.]+: error after reading \d+ bytes? in \d+ seconds?: (?:could not access |system password authentication failed for )user "<F-USER>[^"]+</F-USER>"
13+
failregex = ^%(__prefix_line)sinfo: block\(\d\): tcp/accept \]: <ADDR>\.\d+ \S+: error after reading \d+ bytes? in \d+ seconds?: (?:could not access|system password authentication failed for|pam_authenticate\(\) for) user "<F-USER>[^"]+</F-USER>"
1414

1515
[Init]
1616
journalmatch = _SYSTEMD_UNIT=danted.service

filter.d/dovecot.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/12/15
1+
## Version 2025/08/23
22
# Fail2Ban filter Dovecot authentication and pop3/imap server
33
#
44

@@ -17,12 +17,12 @@ _bypass_reject_reason = (?:: (?:\w+\([^\):]*\) \w+|[^\(]+))*
1717
prefregex = ^%(__prefix_line)s(?:%(_auth_worker)s(?:\([^\)]+\))?: )?(?:%(__pam_auth)s(?:\(dovecot:auth\))?: |(?:pop3|imap|managesieve|submission)-login: )?(?:Info: )?%(_auth_worker_info)s<F-CONTENT>.+</F-CONTENT>$
1818

1919
failregex = ^authentication failure; logname=<F-ALT_USER1>\S*</F-ALT_USER1> uid=\S* euid=\S* tty=dovecot ruser=<F-USER>\S*</F-USER> rhost=<HOST>(?:\s+user=<F-ALT_USER>\S*</F-ALT_USER>)?\s*$
20-
^(?:Aborted login|Disconnected|Remote closed connection|Client has quit the connection)%(_bypass_reject_reason)s \((?:auth failed, \d+ attempts(?: in \d+ secs)?|tried to use (?:disabled|disallowed) \S+ auth|proxy dest auth failed)\):(?: user=<<F-USER>[^>]*</F-USER>>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
20+
^(?:Login aborted|Aborted login|Disconnected|Remote closed connection|Client has quit the connection)%(_bypass_reject_reason)s \((?:auth failed, \d+ attempts(?: in \d+ secs)?|tried to use (?:disabled|disallowed) \S+ auth|proxy dest auth failed)\)[^:]*:(?: user=<<F-USER>[^>]*</F-USER>>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
2121
^pam\(\S+,<HOST>(?:,\S*)?\): pam_authenticate\(\) failed: (?:User not known to the underlying authentication module: \d+ Time\(s\)|Authentication failure \([Pp]assword mismatch\?\)|Permission denied)\s*$
2222
^[a-z\-]{3,15}\(\S*,<HOST>(?:,\S*)?\): (?:[Uu]nknown user|[Ii]nvalid credentials|[Pp]assword mismatch)
2323
<mdre-<mode>>
2424

25-
mdre-aggressive = ^(?:Aborted login|Disconnected|Remote closed connection|Client has quit the connection)%(_bypass_reject_reason)s \((?:no auth attempts|disconnected before auth was ready,|client didn't finish \S+ auth,)(?: (?:in|waited) \d+ secs)?\):(?: user=<[^>]*>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
25+
mdre-aggressive = ^(?:Login aborted|Aborted login|Disconnected|Remote closed connection|Client has quit the connection)%(_bypass_reject_reason)s \((?:no auth attempts|disconnected before auth was ready,|client didn't finish \S+ auth,|disconnected during TLS handshake)(?: (?:in|waited) \d+ secs)?\)[^:]*:(?: user=<[^>]*>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
2626

2727
mdre-normal =
2828

@@ -44,6 +44,7 @@ datepattern = {^LN-BEG}TAI64N
4444
# DEV Notes:
4545
# * the first regex is essentially a copy of pam-generic.conf
4646
# * Probably doesn't do dovecot sql/ldap backends properly (resolved in edit 21/03/2016)
47+
# * Dovecot version 2.4 changed event log structure, line prior needed to maintain 2.3 support
4748
#
4849
# Author: Martin Waschbuesch
4950
# Daniel Black (rewrote with begin and end anchors)

filter.d/dropbear.conf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2024/12/27
22
# Fail2Ban filter for dropbear
33
#
44
# NOTE: The regex below is ONLY intended to work with a patched
@@ -24,14 +24,17 @@ before = common.conf
2424

2525
_daemon = dropbear
2626

27-
prefregex = ^%(__prefix_line)s<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$
27+
prefregex = ^%(__prefix_line)s(?:\[\d+\] \w{2,3} [\d:\s]+)?<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$
2828

29-
failregex = ^[Ll]ogin attempt for nonexistent user ('.*' )?from <HOST>:\d+$
30-
^[Bb]ad (PAM )?password attempt for .+ from <HOST>(:\d+)?$
31-
^[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from <HOST>:\d+\s*$
29+
failregex = ^[Ll]ogin attempt for nonexistent user (?:'<F-USER>.*</F-USER>' )?from <HOST>:\d+$
30+
^[Bb]ad (?:PAM )?password attempt for '<F-USER>.+</F-USER>' from <HOST>(?::\d+)?$
31+
^[Ee]xit before auth from \<?<ADDR>:\d+\>?: (?:\([^\)]*\): )?Max auth tries reached - user '<F-USER>.+</F-USER>'\s*$
32+
^[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '<F-USER>.+</F-USER>' from <HOST>:\d+\s*$
3233

3334
ignoreregex =
3435

36+
journalmatch = _SYSTEMD_UNIT=dropbear.service + _COMM=dropbear
37+
3538
# DEV Notes:
3639
#
3740
# The first two regexs here match the unmodified dropbear messages. It isn't

filter.d/exim-common.conf

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2024/03/25
22
# Fail2Ban filter file for common exim expressions
33
#
44
# This is to be used by other exim filters
@@ -10,12 +10,43 @@ after = exim-common.local
1010

1111
[Definition]
1212

13-
host_info_pre = (?:H=([\w.-]+ )?(?:\(\S+\) )?)?
14-
host_info_suf = (?::\d+)?(?: I=\[\S+\](:\d+)?)?(?: U=\S+)?(?: P=e?smtp)?(?: F=(?:<>|[^@]+@\S+))?\s
15-
host_info = %(host_info_pre)s\[<HOST>\]%(host_info_suf)s
16-
pid = (?: \[\d+\]| \w+ exim\[\d+\]:)?
13+
_fields_grp = (?: (?!H=)[A-Za-z]{1,4}(?:=\S+)?)*
14+
host_info = %(_fields_grp)s (?:H=)?(?:[\w.-]+)? ?(?:\(\S+\))? ?\[<ADDR>\](?::\d+)?%(_fields_grp)s
15+
pid = (?:\s?\[\d+\]|\s?[\w\.-]+ exim\[\d+\]:){0,2}
1716

18-
# DEV Notes:
19-
# From exim source code: ./src/receive.c:add_host_info_for_log
20-
#
21-
# Author: Daniel Black
17+
logtype = file
18+
_add_pref = <lt_<logtype>/_add_pref>
19+
20+
__prefix_line = %(pid)s%(_add_pref)s
21+
22+
[lt_journal]
23+
_add_pref = (?: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})?
24+
25+
[lt_file]
26+
_add_pref =
27+
28+
# DEV Notes
29+
# ------------
30+
# Host string happens:
31+
# H=[ip address]
32+
# H=(helo_name) [ip address]
33+
# H=host_name [ip address]
34+
# H=host_name (helo_name) [ip address]
35+
# flags H=host_name (helo_name) [ip address] flags
36+
# where only [ip address] always visible, ignore ident
37+
# From exim source code:
38+
# src/src/host.c:host_and_ident()
39+
# src/receive.c:add_host_info_for_log()
40+
41+
# Substitution of `_fields_grp` bypasses all flags but H
42+
# Summary of Fields in Log Lines depending on log_selector
43+
# https://www.exim.org/exim-html-current/doc/html/spec_html/ch-log_files.html
44+
# at version exim-4.97.1
45+
# ---
46+
47+
# Authors:
48+
# Cyril Jaquier
49+
# Daniel Black (rewrote with strong regexs)
50+
# Sergey G. Brester aka sebres (optimization, rewrite to prefregex, reviews)
51+
# Martin O'Neal (added additional regexs to detect authentication failures, protocol errors, and drops)
52+
# Vladimir Varlamov (host line definition)

filter.d/exim-spam.conf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2022/08/06
1+
## Version 2024/03/25
22
# Fail2Ban filter for exim the spam rejection messages
33
#
44
# Honeypot traps are very useful for fighting spam. You just activate an email
@@ -27,11 +27,13 @@ before = exim-common.conf
2727

2828
[Definition]
2929

30-
failregex = ^%(pid)s \S+ F=(<>|\S+@\S+) %(host_info)srejected by local_scan\(\): .{0,256}$
31-
^%(pid)s %(host_info)sF=(<>|[^@]+@\S+) rejected RCPT [^@]+@\S+: .*dnsbl.*\s*$
32-
^%(pid)s \S+ %(host_info)sF=(<>|[^@]+@\S+) rejected after DATA: This message contains a virus \(\S+\)\.\s*$
33-
^%(pid)s \S+ SA: Action: flagged as Spam but accepted: score=\d+\.\d+ required=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=\S+ \[<HOST>\]\) for <honeypot>$
34-
^%(pid)s \S+ SA: Action: silently tossed message: score=\d+\.\d+ required=\d+\.\d+ trigger=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=(\S+ )?\[<HOST>\]\) for \S+$
30+
prefregex = ^%(__prefix_line)s<F-CONTENT>.+</F-CONTENT>$
31+
32+
failregex = ^\s?\S+%(host_info)s rejected by local_scan\(\): .{0,256}$
33+
^%(host_info)s rejected RCPT [^@]+@\S+: .*dnsbl.*\s*$
34+
^\s?\S+%(host_info)s rejected after DATA: This message contains a virus \(\S+\)\.\s*$
35+
^\s?\S+ SA: Action: flagged as Spam but accepted: score=\d+\.\d+ required=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=\S+ \[<HOST>\]\) for <honeypot>$
36+
^\s?\S+ SA: Action: silently tossed message: score=\d+\.\d+ required=\d+\.\d+ trigger=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=(\S+ )?\[<HOST>\]\) for \S+$
3537

3638
ignoreregex =
3739

@@ -44,8 +46,6 @@ ignoreregex =
4446

4547
4648

47-
# DEV Notes:
48-
# The %(host_info) defination contains a <HOST> match
49-
#
50-
# Author: Cyril Jaquier
51-
# Daniel Black (rewrote with strong regexs)
49+
# DEV Notes
50+
# -----------
51+
# The %(host_info) definition contains a <ADDR> match. No space before. See exim-common.conf

0 commit comments

Comments
 (0)