[postfix-es] Consulta Fail2ban

Federico Alberto Sayd fsayd en uncu.edu.ar
Jue Ago 1 15:26:41 CEST 2013


On 01/08/13 01:59, Robert J. Briones C. wrote:
> Estimados. debido a un reciente ataque de varias IP desde china he 
> investigado un poco y encontre Fail2ban, según veo es un software 
> interesante que permite bloquear IP que hacen muchos login fallidos y 
> desde diferentes IP
>
> el problema es que no puedo configurar el failregex
>
> he intentado con algunos como estos.
>
> #failregex = warning: (.*)[<HOST>]: SASL LOGIN authentication failed: 
> authentication failure
> #failregex = : warning: .*+\[<HOST>\]: SASL 
> (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed
> failregex = : warning: [-._\w]+\[<HOST>\]: SASL 
> (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed$
>
> unos me dan error y otros no enuentra coincidencia.
>
> las lineas del log que me dan cuenta del error de login son las 
> siguientes
>
> Aug  1 01:27:38 nao postfix/smtpd[31212]: connect from 
> unknown[183.160.126.122]
> Aug  1 01:27:39 nao postfix/smtpd[31212]: warning: 
> unknown[183.160.126.122]: SASL LOGIN authentication failed: 
> authentication failure
> Aug  1 01:27:40 nao postfix/smtpd[31212]: lost connection after AUTH 
> from unknown[183.160.126.122]
> Aug  1 01:27:40 nao postfix/smtpd[31212]: disconnect from 
> unknown[183.160.126.122]
> Aug  1 01:28:24 nao postfix/smtpd[31212]: connect from 
> unknown[60.173.9.227]
> Aug  1 01:28:25 nao postfix/smtpd[31212]: warning: 
> unknown[60.173.9.227]: SASL LOGIN authentication failed: 
> authentication failure
> Aug  1 01:28:26 nao postfix/smtpd[31212]: lost connection after AUTH 
> from unknown[60.173.9.227]
> Aug  1 01:28:26 nao postfix/smtpd[31212]: disconnect from 
> unknown[60.173.9.227]
> Aug  1 01:28:27 nao postfix/smtpd[31212]: connect from 
> unknown[60.173.9.227]
> Aug  1 01:28:28 nao postfix/smtpd[31212]: warning: 
> unknown[60.173.9.227]: SASL LOGIN authentication failed: 
> authentication failure
> Aug  1 01:28:29 nao postfix/smtpd[31212]: lost connection after AUTH 
> from unknown[60.173.9.227]
> Aug  1 01:28:29 nao postfix/smtpd[31212]: disconnect from 
> unknown[60.173.9.227]
>
> y realmente he buscado pero no encuentro que poner para que me 
> funcione el fail2ban.
>
> espero me puedan ayudar.
>
> Saludos.
>
>
A mi me funcionó esta para SASL con postfix:

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

Y sí, las expresiones regulares son un mal necesario, de cualquier forma 
tienes muchas herramientas para testear coincidencias con las 
expresiones regulares que escribas. Fail2ban mismo tiene un herramienta:

fail2ban-regex

Saludos


Más información sobre la lista de distribución postfix-es