Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 18/09/2017, à 22:57

acognard

fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

bonjour,j'ai des log sur asterisk du style :

[2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '46.166.187.224:5733' - Wrong password

je n'arrive pas a banir l adresse 46.166.187.224 qui est je pense à l origine de l'attaque

j'ai je crois essayé quasi tout ce que je pouvais avec mes 'connaissances'

failregex = NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Wrong password
.*NOTICE.* chan_sip.c: Registration from '"\".*\" <sip:5879@MONIP>' failed for '<HOST>:.*' - Wrong password
.*NOTICE.* chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '<HOST>:5733' - Wrong password
.*NOTICE.* chan_sip.c: Registration from ‘"5879" <sip:5879@MONIP>‘ failed for ‘<HOST>:5733‘ - Wrong password
NOTICE[.*] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '<HOST>:5733' - Wrong password
NOTICE[.*] chan_sip.c: Registration from ‘"5879" <sip:5879@MONIP>‘ failed for ‘<HOST>:5733‘ - Wrong password
.*NOTICE[.*] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '<HOST>:5733' - Wrong password
.*NOTICE[.*] chan_sip.c: Registration from ‘"5879" <sip:5879@MONIP>‘ failed for ‘<HOST>:5733‘ - Wrong password
NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - Wrong password
NOTICE.* .*: Registration from ‘\".*\".*‘ failed for ‘<HOST>:.*‘ - Wrong password
NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – Wrong password
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>:*‘ - Wrong password

mais rien n y fait.

mon jail.conf

[asterisk-iptables]
 
enabled  = true
filter   = asterisk
port     = iax,sip,sip-tls
protocol = all
action   = iptables-allports[name=ASTERISK, protocol=all]
           sendmail-whois[name=ASTERISK, dest=root, sender=monemail@gmail.com]
logpath  = /var/log/asterisk/messages
maxretry = 5
bantime = 259200

Merci d'avance pour votre aide.
Arnaud


Modération : merci à l'avenir d'utiliser les balises code (explications ici).

Dernière modification par cqfd93 (Le 18/09/2017, à 23:11)


Arnaud
Auto-Entrepreneur domotique, spécialisé en KNX, intégration Russound, Varuna 3 PRO http://www.idomotique.net
Auto Constructeur KNX http://loftawattrelos.free.fr (Va paraitre dans le numéro de décembre du magasine SystemeD)
Débit descendant :11499 kbit/s · 1437 ko/s ; Débit montant :819 kbit/s · 102 ko/s ; Latence : 86 ms ; IPI : 89

Hors ligne

#2 Le 22/09/2017, à 10:58

crefoin

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

salut,
As-tu vérifié dans ton filtre "asterix" ?
Envoi le contenu de ton filtre asterix

Hors ligne

#3 Le 22/09/2017, à 11:26

bruno

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

Il y a l'outil fail2ban-regexp pour vérifier qu'une ligne (ou un fichier) de log correspond à une expression régulière.

Hors ligne

#4 Le 24/09/2017, à 13:56

acognard

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

bonjour, merci pour vos retours.

@crefoin,

# Fail2Ban configuration file
#
#
# $Revision: 250 $
#

[INCLUDES]

# Read common prefixes. If any customizations available -- read them from
# common.local
#before = common.conf


[Definition]

#_daemon = asterisk

# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values:  TEXT
#

#NOTICE[7208] chan_sip.c: Registration from '"5879" <sip:5879@82.226.111.40>' failed for '46.166.187.224:5733' - Wrong password
failregex = NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Wrong password
.*NOTICE.* chan_sip.c: Registration from '"\".*\" <sip:5879@82.226.111.40>' failed for '<HOST>:.*' - Wrong password
.*NOTICE.* chan_sip.c: Registration from '"5879" <sip:5879@82.226.111.40>' failed for '<HOST>:5733' - Wrong password
.*NOTICE.* chan_sip.c: Registration from ‘"5879" <sip:5879@82.226.111.40>‘ failed for ‘<HOST>:5733‘ - Wrong password
NOTICE[.*] chan_sip.c: Registration from '"5879" <sip:5879@82.226.111.40>' failed for '<HOST>:5733' - Wrong password
NOTICE[.*] chan_sip.c: Registration from ‘"5879" <sip:5879@82.226.111.40>‘ failed for ‘<HOST>:5733‘ - Wrong password
.*NOTICE[.*] chan_sip.c: Registration from '"5879" <sip:5879@82.226.111.40>' failed for '<HOST>:5733' - Wrong password
.*NOTICE[.*] chan_sip.c: Registration from ‘"5879" <sip:5879@82.226.111.40>‘ failed for ‘<HOST>:5733‘ - Wrong password
NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - Wrong password
NOTICE.* .*: Registration from ‘\".*\".*‘ failed for ‘<HOST>:.*‘ - Wrong password
NOTICE.* .*: Registration from ‘.*’ failed for ‘<HOST>’ – Wrong password
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>:*‘ - Wrong password
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - No matching peer found
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Username/auth name mismatch
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Device does not match ACL
NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Peer is not supposed to register
#NOTICE.* <HOST> failed to authenticate as ‘.*‘$
NOTICE.* .*: No registration for peer ‘.*‘ \(from <HOST>\)
NOTICE.* .*: Host <HOST> failed MD5 authentication for ‘.*‘ (.*)
NOTICE.* .*: Failed to authenticate user .*@<HOST>.*
NOTICE.* .*: Registration from ‘.*’ failed for ‘’ – Wrong password
NOTICE.* .*: Registration from ‘.*’ failed for ‘’ – No matching peer found
NOTICE.* .*: Registration from ‘.*’ failed for ‘’ – Username/auth name mismatch
NOTICE.* .*: Registration from ‘.*’ failed for ‘’ – Device does not match ACL
#NOTICE.* failed to authenticate as ‘.*’$
NOTICE.* .*: No registration for peer ‘.*’ \(from \)
NOTICE.* .*: Host failed MD5 authentication for ‘.*’ (.*)
NOTICE.* .*: Failed to authenticate user .*@.*
#NOTICE.*chan_sip.c.*Registration from .* failed for  » – Wrong password
#NOTICE.*chan_sip.c.*Registration from .* failed for .*– Wrong password
#NOTICE.*chan_sip.c.*Registration from .* failed for  » – No matching peer found
#NOTICE.*chan_sip.c.*Registration from .* failed for  » – Username/auth name mismatch
NOTICE.*chan_iax2.c.*register_verify: Host  » did not provide proper plaintext password for.*
NOTICE.*chan_iax2.c.*register_verify: Host  » failed MD5 authentication for .*
NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>' - Wrong password
NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>' - No matching peer found

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =

@bruno,

# fail2ban-regex log:/var/log/asterisk/messages.1og Regex:NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Wrong password
-bash: HOST: Aucun fichier ou dossier de ce type

Merci d'avance.
Arnaud


Arnaud
Auto-Entrepreneur domotique, spécialisé en KNX, intégration Russound, Varuna 3 PRO http://www.idomotique.net
Auto Constructeur KNX http://loftawattrelos.free.fr (Va paraitre dans le numéro de décembre du magasine SystemeD)
Débit descendant :11499 kbit/s · 1437 ko/s ; Débit montant :819 kbit/s · 102 ko/s ; Latence : 86 ms ; IPI : 89

Hors ligne

#5 Le 24/09/2017, à 16:41

bruno

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

Ce n'est comme cela que fail2ban-regex s'utilise, voir :

http://www.fail2ban.org/wiki/index.php/ … _8#Testing

Quelle version de fail2ban utilises-tu ? Pourquoi cette  ligne est-elle commentée ?

#before = common.conf

EDIT: si je teste ta ligne de log avec le fichier asterisk.conf fourni part fail2ban 0.9 j'ai bien une correspondance :

$ fail2ban-regex "[2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '46.166.187.224:5733' - Wrong password" /etc/fail2ban/filter.d/asterisk.conf 

Running tests
=============

Use   failregex filter file : asterisk, basedir: /etc/fail2ban
Use      single line : [2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Re...

[...]

Lines: 1 lines, 0 ignored, 1 matched, 0 missed [processed in 0.00 sec] 

Dernière modification par bruno (Le 24/09/2017, à 16:49)

Hors ligne

#6 Le 25/09/2017, à 08:03

acognard

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

hello, merci pour ton retour.

j'ai décommenté la ligne, aucune idée pourquoi ca l'était. Je pense pas en etre le responsable.
Ma version est la

:~# fail2ban-regex -V
Fail2Ban v0.8.6

j'ai testé la meme commande que toi :

# fail2ban-regex "[2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '46.166.187.224:5733' - Wrong password" /etc/fail2ban/filter.d/asterisk.conf

Running tests
=============

Use regex file : /etc/fail2ban/filter.d/asterisk.conf
Use single line: [2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Re...


Results
=======

Failregex
|- Regular expressions:
|  [1] NOTICE.* .*: Registration from ‘.*‘ failed for ‘<HOST>‘ - Wrong password
|
`- Number of matches:
   [1] 0 match(es)

Ignoreregex
|- Regular expressions:
|
`- Number of matches:

Summary
=======

Sorry, no match

Look at the above section 'Running tests' which could contain important
information.

Donc ca m a l air de fonctionner.
mon fichier tail -f /var/log/asterisk/messages devient correct.
par contre le fichier de log fail2ban tail -f /var/log/fail2ban.log est vide ?

cdlmnt.
Arnaud


Arnaud
Auto-Entrepreneur domotique, spécialisé en KNX, intégration Russound, Varuna 3 PRO http://www.idomotique.net
Auto Constructeur KNX http://loftawattrelos.free.fr (Va paraitre dans le numéro de décembre du magasine SystemeD)
Débit descendant :11499 kbit/s · 1437 ko/s ; Débit montant :819 kbit/s · 102 ko/s ; Latence : 86 ms ; IPI : 89

Hors ligne

#7 Le 25/09/2017, à 08:32

bruno

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

Non cela ne fonctionne pas, puisque tu obtiens :

Sorry, no match

Le même test sur une ubuntu 14.04 avec fail2an 0.8.11 donne aussi une correspondance :

$ fail2ban-regex "[2017-09-18 23:50:34] NOTICE[11789] chan_sip.c: Registration from '"5879" <sip:5879@MONIP>' failed for '46.166.187.224:5733' - Wrong password" /etc/fail2ban/filter.d/asterisk.conf
[...]
Lines: 1 lines, 0 ignored, 1 matched, 0 missed

Si cela fonctionne avec les filtres par défaut de fail2ban, c'est que tu dois revenir au fichier asterisk.conf d'origine. D'ailleurs la structure du fichier que tu donnes en #4 correspond à fail2ban 0.9 et non fail2ban 0.8. J'ai l'impression qu'il y a un gros bidouillage dans ta configuration de fail2ban avec des copier/coller hasardeux…

Dernière modification par bruno (Le 25/09/2017, à 08:35)

Hors ligne

#8 Le 25/09/2017, à 10:07

acognard

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

Re,
bon, apt-get remove fail2ban
delete du répertoire /etc/fail2ban
apt-get install fail2ban
et la, le repertoire est bien créé, mais vide sad

j ai tenté via aptitude, idem !
je comprends pas....

Tks.


Arnaud
Auto-Entrepreneur domotique, spécialisé en KNX, intégration Russound, Varuna 3 PRO http://www.idomotique.net
Auto Constructeur KNX http://loftawattrelos.free.fr (Va paraitre dans le numéro de décembre du magasine SystemeD)
Débit descendant :11499 kbit/s · 1437 ko/s ; Débit montant :819 kbit/s · 102 ko/s ; Latence : 86 ms ; IPI : 89

Hors ligne

#9 Le 25/09/2017, à 10:11

bruno

Re : fail2ban avec asterisk ne bannit pas failed for '46.166.187.224:5733'

Pour désinstaller complètement un paquet y compris ses fichiers de configuration :

sudo aptitude purge fail2ban

Avant de réinstaller, mettre à jour les dépôts :

sudo aptitude update
sudo aptitude full-upgrade

Hors ligne