Pular para o conteúdo

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.
Ricardo Brito do Nascimento rbn_jesus
Hits: 78.695 Categoria: Linux Subcategoria: Segurança
  • Indicar
  • Impressora
  • Denunciar

Parte 3: 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.
   1. Introdução e Instalação do fail2ban
   2. Configuração para fail2ban
   3. Exemplos e Referências

Explorando o wget

Conexão com chaves assimétricas sem uso de senha em servidor sshd

Configurando Subversion

Instalação Plone 2.5.5 com módulos customizados

Comando sudo - instalação e configuração

Autenticação de servidores CentOS/Red Hat 6 em Windows 2008

Nikto - Tutorial básico e avançado

Escrevendo em discos sem sistemas de arquivos

Computação Forense - Entendendo uma perícia

Honeypot Kippo 0.8 - Instalação e utilização

#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

Entre na sua conta para comentar.