Fail2Ban smtp dovecot pop3 etc..

LessSecurity

New Member
[Gelöst] Fail2Ban smtp dovecot pop3 etc..

Nach einigen Stunden weiterer Arbeit hab ich die Probleme scheinbar in den Griff bekommen. Die Sache hat sich also doch erledigt, und bald ist Bettzeit ;)

Hallo.

Ich habe einen vserver, den ich mit Hilfe von iptables und fail2ban hoffe, relativ gut absichern zu können.

Muss dazu aber gestehen, dass ich noch recht am Anfang mit meinem Wissen stehe.

OS: Debian Squeeze Kernel 2.6.32-5-xen-amd64
Fail2ban v0.8.4-SVN
Dovecot 1.2.15
Postfix: 2.7.1
(Braucht ihr mehr Infos?)

Mit iptables ist alles super, aber fail2ban macht mir ein paar Probleme.

1. Eine Bruteforceattacke auf den SSH wird zuverlässig von EXAKT DEM Port gebannt. Allerdings soll der Attacker komplett gebannt werden, also quasi das Gleiche machen wie
Code:
 iptables -A INPUT -s 1.2.3.4 .j REJECT
Nur wie?

2. Ich kriege das hier nicht weg:

Code:
Oct 13 03:27:41 mypc postfix/smtpd[678]: warning: bruterhost[bruterip]: SASL CRAM-MD5 authentication failed: authentication failure
Oct 13 03:57:33 mypc postfix/smtpd[2015]: warning: unknown[bruterip]: SASL LOGIN authentication failed: authentication failure

In meinem "Wahn" habe ich ohne Ende herumexperimentiert, in der jail.conf habe ich sasl postfix courier und courierauth enabled. Half nichts.

Danach eine jail.local angelegt:
Code:
[dovecot-pop3imap]
enabled = true
filter = dovecot-pop3imap
port = pop3,pop3s,imap,imaps
action = iptables-multiport[name=dovecot-pop3imap, port="pop3,pop3s,imap,imaps", protocol=tcp]
# optionaly mail notification # mail[name=dovecot-pop3imap, dest=root@domain] # see /etc/fail2ban/action.d/ or Fail2Ban doc
logpath = /var/log/syslog
maxretry = 4
findtime = 120000
bantime = 1200

[sasl]

enabled  = true
port	 = smtp,ssmtp
filter   = sasl
action = iptables-multiport[name=dovecot-pop3imap, port="smtp,ssmtp", protocol=tcp]
# You might consider monitoring /var/log/warn.log instead
# if you are running postfix. See http://bugs.debian.org/507990
logpath  = /var/log/mail.warn
maxretry = 4
findtime = 120000
bantime = 1200

Die /filter.d/sasl.conf (gekürzt, ohne Abschnitt dovecot-pop3imap.conf)

Code:
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [A-Za-z0-9+/]*={0,2})?$
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [A-Za-z0-9+/]*={0,2})?$
failregex = [?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed$
failregex = : warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed$

ignoreregex =
Zugegeben, regex liegt mir nicht, und ich hab genommen was ich fand.

Nachdem ich auch viel gespielt habe, tauchen im fail2ban.log einige Fehler beim Beenden von f2b auf:

Code:
2012-10-15 00:58:21,969 fail2ban.actions.action: ERROR  iptables -D INPUT -p tcp -m multiport --dports pop3,pop3s,imap,imaps -j fail2ban-dovecot-pop3imap
iptables -F fail2ban-dovecot-pop3imap
iptables -X fail2ban-dovecot-pop3imap returned 100
2012-10-15 00:58:21,970 fail2ban.jail   : INFO   Jail 'dovecot-pop3imap' stopped
2012-10-15 00:58:22,958 fail2ban.actions.action: ERROR  iptables -D INPUT -p tcp -m multiport --dports smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s -j fail2ban-courierauth
iptables -F fail2ban-courierauth
iptables -X fail2ban-courierauth returned 100
2012-10-15 00:58:24,935 fail2ban.actions.action: ERROR  iptables -D INPUT -p tcp -m multiport --dports smtp,ssmtp -j fail2ban-dovecot-pop3imap
iptables -F fail2ban-dovecot-pop3imap
iptables -X fail2ban-dovecot-pop3imap returned 100

Also so langsam weiß ich nicht mehr weiter, und wäre sehr dankbar, wenn mir wer den entscheidenden Tip geben könnte, wie ich das richtig hinbekomme.
 
Last edited by a moderator:
Oh, Punkt 2 ist gelöst.

Erfolgreicher Ban nachdem ich noch 2 andere failregex angefügt habe.

Und von den letzten Fehlermeldungen ist auch nicht mehr viel über.
 
Back
Top