Proteção utilizando fail2ban contra ataques do tipo

O fail2ban pode monitorar a tentativa de login nos serviços ssh, pam, xinetd, apache, vsftpd, proftpd, wuftpd, postfix, couriersmtp, courierauth, sasl e named, e em uma ação pró-ativa bloquear o possível ataque, adicionando uma regra no firewall.

[ Hits: 76.607 ]

Por: Ricardo Brito do Nascimento em 30/08/2011 | Blog: http://brito.blog.incolume.com.br


Exemplos e Referências



Exemplos para fail2ban

Exemplo de monitoração ao PAM e xinetd:

...
[pam-generic]

enabled = false
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter  = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port = all
banaction = iptables-allports
port     = anyport
logpath  = /var/log/auth.log
maxretry = 6

[xinetd-fail]

enabled   = false
filter    = xinetd-fail
port      = all
banaction = iptables-multiport-log
logpath   = /var/log/daemon.log
maxretry  = 2
...

Exemplo de monitoração ao apache:

...
#
# HTTP servers
#

[apache]

enabled = false
port    = http,https
filter  = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 6

# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (<0.7.6-2) releases
[apache-multiport]

enabled   = false
port      = http,https
filter    = apache-auth
logpath   = /var/log/apache*/*error.log
maxretry  = 6

[apache-noscript]

enabled = false
port    = http,https
filter  = apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 6

[apache-overflows]

enabled = false
port    = http,https
filter  = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2
...

Exemplo de monitoração ao FTP:

...
#
# FTP servers
#

[vsftpd]

enabled  = false
port     = ftp,ftp-data,ftps,ftps-data
filter   = vsftpd
logpath  = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 6


[proftpd]

enabled  = false
port     = ftp,ftp-data,ftps,ftps-data
filter   = proftpd
logpath  = /var/log/proftpd/proftpd.log
maxretry = 6


[wuftpd]

enabled  = false
port     = ftp,ftp-data,ftps,ftps-data
filter   = wuftpd
logpath  = /var/log/auth.log
maxretry = 6
...

Exemplo de monitoração ao DNS:

...
# DNS Servers


# These jails block attacks against named (bind9). By default, logging is off
# with bind9 installation. You will need something like this:
#
# logging {
#     channel security_file {
#         file "/var/log/named/security.log" versions 3 size 30m;
#         severity dynamic;
#         print-time yes;
#     };
#     category security {
#         security_file;
#     };
# };
#
# in your named.conf to provide proper logging

# Word of Caution:
# Given filter can lead to DoS attack against your DNS server
# since there is no way to assure that UDP packets come from the
# real source IP

[named-refused-udp]

enabled  = false
port     = domain,953
protocol = udp
filter   = named-refused
logpath  = /var/log/named/security.log

[named-refused-tcp]

enabled  = false
port     = domain,953
protocol = tcp
filter   = named-refused
logpath  = /var/log/named/security.log
...

Referências

O arquivo pdf pode ser encontrado em http://brito.blog.incolume.com.br.
Página anterior    

Páginas do artigo
   1. Introdução e Instalação do fail2ban
   2. Configuração para fail2ban
   3. Exemplos e Referências
Outros artigos deste autor

Configurando Subversion

Clonagem de Hardware Hotline em Software Livre

Formatando exibição de datas no Linux

CMS Plone 4.1.6 com invólucro Virtualenv + Buildout + Mount Point + BLOB Storage + Unicode UTF-8

Gerenciando certificados A1 fornecidos pelo ICB-Brasil no navegador Chrome sobre Linux

Leitura recomendada

Defesa pessoal com o GPG, Nautilus Scripts, partições encriptadas e leves doses de paranoia

Gerar par de chaves com o GnuPG em 11 passos

Analizando os logs do IPTables

Recon and Scan with Metasploit

Servidor SSH (Secure Shell Hosting)

  
Comentários
[1] Comentário enviado por removido em 30/08/2011 - 15:01h

Muito bom !

[2] Comentário enviado por rbn_jesus em 19/10/2011 - 10:04h

obrigado Thalysson!

[3] Comentário enviado por alex.oliver em 28/09/2012 - 09:14h

Olá Ricardo!

Sensacional o artigo, estou iniciando um trabalho com essa ferramenta, e tenho uma dúvida... na opção "enable = false", esta estaria ativando a monitoração desejada ou estaria stopando-a?
Fiquei em dúvida, porque estou usando o arquivo jail.* como a extensão .local, teria algo a ver ou viajei muito?!

Abraços!

[4] Comentário enviado por sylviomgs em 28/06/2016 - 13:31h

Boa tarde, Ótimo artigo, gostaria de saber onde visualizo a blacklist q o fail2ban cria...

[5] Comentário enviado por davidfagundes em 08/12/2017 - 15:16h

muito bom o artigo, tenho uma pergunta, consigo bloquear ao invés do IP o MAC ??


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts