Soucis Fail2ban

Hello,

Comme annoncé voici mon 2ème soucis, j’ai installé fail2ban mais mes jail ne semble pas toutes fonctionné.
J’ai activé notamment la protection contre les scripts w00t-w00t visant Apache et les logs de fail2ban montre qu’il est actif : 2013-08-23 15:22:41,000 fail2ban.actions: WARNING [apache-w00tw00t] Ban 184.22.58.49 2013-08-23 15:32:41,789 fail2ban.actions: WARNING [apache-w00tw00t] Unban 184.22.58.49 ...

Par contre j’ai aussi tenté de filtrer les attaques brute force sur Squirrelmail et Roundcubemail mais cette fois sans succès…
Voici un extrait de /etc/jail.local : [code][roundcube]
enabled = true
port = http,https
filter = roundcube
action = iptables-multiport[name=roundcube, port=“http,https”]
logpath = /var/www/roundcubemail/logs/userlogins

[squirrelmail]
enabled = true
port = http,https
filter = squirrelmail
action = iptables-multiport[name=squirrelmail, port=“http,https”]
logpath = /var/log/squirrelmail.log
maxretry = 4[/code]

Et maintenant mes filtres :
squirellmail.conf : [Definition] failregex = [[]LOGIN_ERROR[]] .*. from <HOST>: Unknown user or password incorrect. ignoreregex =
roundcube.conf : [Definition] failregex = FAILED login for .*. from <HOST> ignoreregex =

Quand je teste de me connecter plusieurs fois avec un mot de passe erroné je bien des lignes dans les log respectifs :
squirrelmail Aug 22 17:34:45 [LOGIN_ERROR] sdfg (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 22 17:34:53 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 22 17:35:05 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 22 17:35:25 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 22 17:35:44 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 22 17:36:01 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect.
Et le test des expression me remonte bien des IP : [code]# fail2ban-regex /var/log/squirrelmail.log /etc/fail2ban/filter.d/squirrelmail.conf

Running tests

Use regex file : /etc/fail2ban/filter.d/squirrelmail.conf
Use log file : /var/log/squirrelmail.log

Matched time template Year-Month-Day Hour:Minute:Second
Got time using template Year-Month-Day Hour:Minute:Second

Results

Failregex: 33 total
|- #) [# of hits] regular expression
| 1) [33] [[]LOGIN_ERROR[]] .*. from : Unknown user or password incorrect.
`-

Ignoreregex: 0 total

Summary

Addresses found:
[1]
95.136.128.5 (Mon Aug 19 19:53:05 2013)
95.136.128.5 (Mon Aug 19 19:53:14 2013)
95.136.128.5 (Mon Aug 19 19:53:26 2013)

Date template hits:
16 hit(s): MONTH Day Hour:Minute:Second
60 hit(s): Year-Month-Day Hour:Minute:Second

Success, the total number of match is 33

However, look at the above section ‘Running tests’ which could contain important
information.[/code]
Et même chose pour roundcube : [22-Aug-2013 17:46:01 +0000]: FAILED login for namour from 95.136.128.5 [22-Aug-2013 17:46:09 +0000]: FAILED login for namour from 95.136.128.5 [22-Aug-2013 17:46:21 +0000]: FAILED login for namour from 95.136.128.5 [22-Aug-2013 17:46:41 +0000]: FAILED login for namour from 95.136.128.5 [22-Aug-2013 17:47:02 +0000]: FAILED login for namour from 95.136.128.5 [22-Aug-2013 17:47:22 +0000]: FAILED login for namour from 95.136.128.5

[code]# fail2ban-regex /var/www/roundcubemail/logs/userlogins /etc/fail2ban/filter.d/roundcube.conf

Running tests

Use regex file : /etc/fail2ban/filter.d/roundcube.conf
Use log file : /var/www/roundcubemail/logs/userlogins

Matched time template Day-MONTH-Year Hour:Minute:Second[.Millisecond]
Got time using template Day-MONTH-Year Hour:Minute:Second[.Millisecond]

Results

Failregex: 16 total
|- #) [# of hits] regular expression
| 1) [16] FAILED login for .*. from
`-

Ignoreregex: 0 total

Summary

Addresses found:
[1]
95.136.128.5 (Mon Aug 19 20:09:37 2013)
95.136.128.5 (Mon Aug 19 20:42:59 2013)

Date template hits:
46 hit(s): Day-MONTH-Year Hour:Minute:Second[.Millisecond]

Success, the total number of match is 16

However, look at the above section ‘Running tests’ which could contain important
information.[/code]

Et pourtant aucun ban, des idées ?

Salut,

Ne sont-elles pas déjà bannies … ?

Non je n’ai rien dans iptables de plus je fais des tests depuis mon PC de bureau et j’ai toujours accès au serveur.

N’as tu pas déclaré ton ip comme autorisé (ignoré) ?

[code]~ # nano /etc/fail2ban/jail.conf

“ignoreip” can be an IP address, a CIDR mask or a DNS host

ignoreip = 127.0.0.1/8 95.xxx.xxx.xxx

[/code]

Bonne idée mais je n’ai que localhost (/etc/fail2ban/jail.con et /etc/fail2ban/jail.local) : [code]# “ignoreip” can be an IP address, a CIDR mask or a DNS host. Fail2ban will not

ban a host which matches an address in this list. Several addresses can be

defined using space separator.

ignoreip = 127.0.0.1/8

“bantime” is the number of seconds that a host is banned.

bantime = 600[/code]

En tout cas merci de chercher pour moi.

Dans les logs (/var/log/fail2ban.log, … /var/log/fail2ban.log.1 … 2, 3 ou plus généralement en /var/log/fail2ban.log.gz, selon la configuration faite en logrotate) du :

?

Les seules lignes concernant mon IP dans /etc/log/fail2ban.log* sont : 2013-08-23 20:40:22,192 fail2ban.filter : WARNING Determined IP using DNS Lookup: 5.128.136.95.rev.sfr.net = ['95.136.128.5'] Après chaque restart du service… Pourquoi :017

Salut,

Comment procèdes tu pour effectuer ces tests ?

PC de bureau ==> en local.
accès au serveur ==> ???

Mon PC de bureau est celui sur lequel je suis physiquement, pendant mes tests je suis connecté en SSH à mon serveur pour me deban en cas de succès de Fail2ban.

Je sais que j’ai encore accès au serveur car je joint encore mes webmails via firefox même après 6 échecs d’authentification.

Je vais devoir être plus explicite alors …

Il est ou ce serveur ?

OVH Roubaix.

Question un peu bête … les plugins en causes, sont-ils installés ? Comment ? ou ?

Comme il y a bien des entrées dans les fichiers de log pour moi les plug-ins de squirrelmail et Roundcube sont bien installé.

[code]# pwd
/var/www/roundcubemail/plugins/fail2ban

ls -l

total 44
-rw-r–r-- 1 www-data www-data 877 juin 19 2011 fail2ban.php
-rw-r–r-- 1 www-data www-data 35147 juin 19 2011 LICENSE
-rw-r–r-- 1 www-data www-data 1359 juin 19 2011 README.md
[/code]

[code]SquirrelMail Configuration : Read: config.php (1.4.0)

Plugins
Installed Plugins
1. view_as_html
2. squirrel_logger

Available Plugins:
3. administrator
4. bug_report

[/code]

Je ne vois pas trop ce qui coince.

Renouvelles tes tests et suis tes logs en live.

Ouvres une console, passes en root, dans cette dernière à l’aide des touches Ctrl (droit) + Maj + T (te permettra d’ouvrir x consoles dans cette même console)

Nota : il te faudra à chaque nouvelle console (Ctrl (droit) + Maj + T) informer ton mdp.

Nota: Pour fermer l’une d’elle (places toi dans cette dernière) et actionne Ctrl (droit) + D

Lances les trois consoles (minimum) avant de tester pc-bureau => serveur distant

Nota: plus postfix (il me semble) et apache … mange pas de pain ça !

Les log se remplissent bien :
/var/log/squirrelmail.log [24-Aug-2013 14:20:49 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:50 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:51 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:53 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:54 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:55 +0000]: FAILED login for namour from 95.136.128.5 [24-Aug-2013 14:20:57 +0000]: FAILED login for namour from 95.136.128.5
/var/www/roundcubemail/logs/userlogins Aug 24 14:21:01 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 24 14:21:09 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 24 14:22:02 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 24 14:22:07 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 24 14:22:31 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect. Aug 24 14:22:46 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect.

Mais pas de réaction de fail2ban 2013-08-24 16:19:25,537 fail2ban.jail : INFO Creating new jail 'roundcube' 2013-08-24 16:19:25,538 fail2ban.jail : INFO Jail 'roundcube' uses pyinotify 2013-08-24 16:19:25,571 fail2ban.jail : INFO Initiated 'pyinotify' backend 2013-08-24 16:19:25,575 fail2ban.filter : INFO Added logfile = /var/www/roundcubemail/logs/userlogins 2013-08-24 16:19:25,578 fail2ban.filter : INFO Set maxRetry = 3 2013-08-24 16:19:25,581 fail2ban.filter : INFO Set findtime = 600 2013-08-24 16:19:25,583 fail2ban.actions: INFO Set banTime = 600 2013-08-24 16:19:25,617 fail2ban.jail : INFO Creating new jail 'squirrelmail' 2013-08-24 16:19:25,617 fail2ban.jail : INFO Jail 'squirrelmail' uses pyinotify 2013-08-24 16:19:25,655 fail2ban.jail : INFO Initiated 'pyinotify' backend 2013-08-24 16:19:25,659 fail2ban.filter : INFO Added logfile = /var/log/squirrelmail.log 2013-08-24 16:19:25,662 fail2ban.filter : INFO Set maxRetry = 4 2013-08-24 16:19:25,665 fail2ban.filter : INFO Set findtime = 600 2013-08-24 16:19:25,667 fail2ban.actions: INFO Set banTime = 600 2013-08-24 16:19:25,706 fail2ban.jail : INFO Jail 'ssh' started 2013-08-24 16:19:25,714 fail2ban.jail : INFO Jail 'ssh-ddos' started 2013-08-24 16:19:25,720 fail2ban.jail : INFO Jail 'apache' started 2013-08-24 16:19:25,724 fail2ban.jail : INFO Jail 'apache-noscript' started 2013-08-24 16:19:25,728 fail2ban.jail : INFO Jail 'apache-overflows' started 2013-08-24 16:19:25,733 fail2ban.jail : INFO Jail 'vsftpd' started 2013-08-24 16:19:25,738 fail2ban.jail : INFO Jail 'postfix' started 2013-08-24 16:19:25,741 fail2ban.jail : INFO Jail 'sasl' started 2013-08-24 16:19:25,744 fail2ban.jail : INFO Jail 'dovecot' started 2013-08-24 16:19:25,749 fail2ban.jail : INFO Jail 'apache-w00tw00t' started 2013-08-24 16:19:25,757 fail2ban.jail : INFO Jail 'apache-phpmyadmin' started 2013-08-24 16:19:25,762 fail2ban.jail : INFO Jail 'roundcube' started 2013-08-24 16:19:25,767 fail2ban.jail : INFO Jail 'squirrelmail' started 2013-08-24 16:20:14,447 fail2ban.filter : WARNING Determined IP using DNS Lookup: 5.128.136.95.rev.sfr.net = ['95.136.128.5']

Et rien dans iptables [code]Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-squirrelmail tcp – anywhere anywhere multiport dports http,https
fail2ban-roundcube tcp – anywhere anywhere multiport dports http,https

Chain fail2ban-roundcube (1 references)
target prot opt source destination
RETURN all – anywhere anywhere

Chain fail2ban-squirrelmail (1 references)
target prot opt source destination
RETURN all – anywhere anywhere[/code]

[quote][24-Aug-2013 14:20:57 +0000]: FAILED login for namour from 95.136.128.5

Aug 24 14:21:01 [LOGIN_ERROR] N/A (caladan.siberien.tf) from 95.136.128.5: Unknown user or password incorrect.

2013-08-24 16:19:25,537 fail2ban.jail : INFO Creating new jail ‘roundcube’[/quote]

En live ?

On tient une piste je pense, l’heure des logs est 2 heures en retard sur l’heure système…

Après ajout de date.timezone = "Europe/Paris" dans /etc/php5/apache2/php.ini cela fonctionne.

Merci bcp pour ton aide :023

Cool !!

Pour la pérennité.

Peut-on savoir ce qui t’a conduit à cette modification de php … ?

Les plugins de roundcube et squirrelmail étant écrit en php j’ai ouvert mon php.in et chercher “time”, au bout d’un moment je suis tombé sur "date.timezone = " et j’ai donc rajouter “Europe/Paris” grâce aux exemples en commentaire juste au dessus.
J’ai testé, je me suis fait ban :041 et j’ai ouvert une bière :laughing:

J’ai fait un upgrade sauvage de ma Debian, je pense que je vais encore avoir des surprises comme celle-ci.