diff --git a/ChangeLog b/ChangeLog index ae7d51c3..1c4620d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ releases. * filter.d/asterisk.conf - fixed failregex AMI Asterisk authentification failed (see gh-1302) * filter.d/dovecot.conf - fixed failregex, see gh-1879 (partially cherry-picked from gh-1880) * filter.d/exim.conf - fixed failregex for case of flood attempts with `D=0s` (gh-1887) +* filter.d/postfix-*.conf - added optional port regex (gh-1902) ### New Features diff --git a/config/filter.d/postfix-rbl.conf b/config/filter.d/postfix-rbl.conf index 0a9078f0..10bd98d7 100644 --- a/config/filter.d/postfix-rbl.conf +++ b/config/filter.d/postfix-rbl.conf @@ -11,8 +11,9 @@ before = common.conf [Definition] _daemon = postfix(-\w+)?/smtpd +_port = (?::\d+)? -failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]: [45]54 [45]\.7\.1 Service unavailable; Client host \[\S+\] blocked\b +failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]%(_port)s: [45]54 [45]\.7\.1 Service unavailable; Client host \[\S+\] blocked\b ignoreregex = diff --git a/config/filter.d/postfix-sasl.conf b/config/filter.d/postfix-sasl.conf index 1a24ca94..d354b74a 100644 --- a/config/filter.d/postfix-sasl.conf +++ b/config/filter.d/postfix-sasl.conf @@ -8,8 +8,9 @@ before = common.conf [Definition] _daemon = postfix(-\w+)?/(?:submission/|smtps/)?smtp[ds] +_port = (?::\d+)? -failregex = ^%(__prefix_line)swarning: [-._\w]+\[\]: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(:[ A-Za-z0-9+/:]*={0,2})?\s*$ +failregex = ^%(__prefix_line)swarning: [-._\w]+\[\]%(_port)s: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(:[ A-Za-z0-9+/:]*={0,2})?\s*$ ignoreregex = authentication failed: Connection lost to authentication server$ diff --git a/config/filter.d/postfix.conf b/config/filter.d/postfix.conf index 3051409b..7255384e 100644 --- a/config/filter.d/postfix.conf +++ b/config/filter.d/postfix.conf @@ -11,14 +11,15 @@ before = common.conf [Definition] _daemon = postfix(-\w+)?/(?:submission/|smtps/)?smtp[ds] +_port = (?::\d+)? -failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]: 554 5\.7\.1 .*$ - ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]: 450 4\.7\.1 Client host rejected: cannot find your hostname, (\[\S*\]); from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ - ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]: 450 4\.7\.1 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$ - ^%(__prefix_line)sNOQUEUE: reject: EHLO from \S+\[\]: 504 5\.5\.2 <\S+>: Helo command rejected: need fully-qualified hostname; - ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[\]: 550 5\.1\.1 .*$ - ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]: 450 4\.1\.8 <\S*>: Sender address rejected: Domain not found; from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ - ^%(__prefix_line)simproper command pipelining after \S+ from [^[]*\[\]:?$ +failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]%(_port)s: 554 5\.7\.1 .*$ + ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]%(_port)s: 450 4\.7\.1 Client host rejected: cannot find your hostname, (\[\S*\]); from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ + ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]%(_port)s: 450 4\.7\.1 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$ + ^%(__prefix_line)sNOQUEUE: reject: EHLO from \S+\[\]%(_port)s: 504 5\.5\.2 <\S+>: Helo command rejected: need fully-qualified hostname; + ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[\]%(_port)s: 550 5\.1\.1 .*$ + ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[\]%(_port)s: 450 4\.1\.8 <\S*>: Sender address rejected: Domain not found; from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ + ^%(__prefix_line)simproper command pipelining after \S+ from [^[]*\[\]%(_port)s:?$ ignoreregex = diff --git a/fail2ban/tests/files/logs/postfix-sasl b/fail2ban/tests/files/logs/postfix-sasl index cdcb5121..fef2076b 100644 --- a/fail2ban/tests/files/logs/postfix-sasl +++ b/fail2ban/tests/files/logs/postfix-sasl @@ -30,3 +30,5 @@ Apr 12 02:24:11 xxx postfix/smtps/smtpd[42]: warning: astra4139.startdedicated.d # failJSON: { "time": "2005-08-03T15:30:49", "match": true , "host": "98.191.84.74" } Aug 3 15:30:49 ksusha postfix/smtpd[17041]: warning: mail.foldsandwalker.com[98.191.84.74]: SASL Plain authentication failed: +# failJSON: { "time": "2005-08-04T16:47:52", "match": true , "host": "192.0.2.237", "desc": "cover optional port after host" } +Aug 4 16:47:52 mail3 postfix/smtpd[31152]: warning: unknown[192.0.2.237]:55729: SASL LOGIN authentication failed: authentication failure