2010/3/18 Felipe N. Oliva <felipe.n...@yahoo.com.br>: > Tenho o bruteblock em alguns servidores para controle de conexão no > smtp, ele le o arquivo de log e adiciona automaticamente o ip com um > determinado numero de conexões em uma tabela do ipfw.
Aqui estão. Algumas linhas foram quebradas, mas com um pouco de atenção pode-se ver como consertar. São basicamente as regex. ssh.conf: ---- 8x ---- Cut Here ---- Corte aqui ---- # Sample configuration file for the OpenSSH daemon # regexp rule. Please rember that you MUST specify only one match for # ip address to block # # this regexp for the OpenSSH server matches lines like: # # comment: auth via key only #sshd[72593]: Illegal user hacker from 1.2.3.4 # # comment: pwd auth, but no such user #sshd[72593]: Failed password for illegal user sammmm from 1.2.3.4 # # comment: correct user, but wrong password #sshd[72626]: Failed password for samm from 1.2.3.4 # # Versao aprimorada de regras implementada em 18/11/2006 # A versao anterior estah num arquivo com a data no final do nome. regexp = sshd.*Illegal user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp1 = sshd.*Failed password for (?:illegal user )?\S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp2 = sshd.*Did not receive identification string from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp3 = sshd.*Invalid user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp4 = sshd.*reverse mapping checking getaddrinfo for .* .(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}). failed - POSSIBLE BREAK-IN ATTEMPT! # Number of failed login attempts within time before we block max_count = 4 # Time in seconds in which all failed login attempts must occur # Modificado por Joao Rocha em 30/08/2006. #within_time = 60 within_time = 300 # Time in seconds to block ip in firewall # 10 minutes # Modificado por Joao Rocha em 30/08/2006. #reset_ip = 600 reset_ip = 14400 # IPFW table number to add "bad" hosts # Modificado por Joao Rocha em 30/08/2006. #ipfw2_table_no = 1 ipfw2_table_no = 0 ---- 8x ---- Cut Here ---- Corte aqui ---- ftp: ---- 8x ---- Cut Here ---- Corte aqui ---- # Sample configuration file for the ProFTPD daemon # regexp rule. Please rember that you MUST specify only one match for # ip address to block # # this regexp for the ProFTPD server matches lines like: # # proftpd[71905]: server.com (hack.com[1.2.3.4]) - USER hacker: no such user # proftpd[72020]: server.com (hack.com[1.2.3.4]) - USER hacker (Login failed) # # Illegal user test from 10.0.0.1 # Failed password for illegal user x from 10.0.0.1 port x ssh2 # Failed password for x from 10.0.0.1 port x ssh2 #regexp = (?:did not receive identification string from|illegal user .+ from|failed .+ for (?:illegal user )?.+ from).*\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).* #regexp=Did not receive identification string from 10.0.0.1 #regexp=proftpd.*\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]\) - USER \S+ (?:no such user|\(Login failed) regexp =ftpd.*: FTP LOGIN FAILED FROM (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) # Number of failed login attempts within time before we block max_count = 4 # Time in seconds in which all failed login attempts must occur #within_time = 60 within_time = 300 # Time in seconds to block ip in firewall # 10 minutes #reset_ip = 600 reset_ip = 14400 # IPFW table number to add "bad" hosts #ipfw2_table_no = 0 ipfw2_table_no = 0 ---- 8x ---- Cut Here ---- Corte aqui ---- Acrescente a seguinte linha no ---- 8x ---- Cut Here ---- Corte aqui ---- auth.info;authpriv.info | exec /usr/local/sbin/bruteblock -f /usr/local/etc/bruteblock/ssh.conf auth.info | exec /usr/local/sbin/bruteblock -f /usr/local/etc/bruteblock/ftp.conf ---- 8x ---- Cut Here ---- Corte aqui ---- João Rocha. > > Joao, voce poderia enviar os arquivos de configuração para ssh e ftp? >> 2010/3/17 Davi Vercillo C. Garcia <davivcgar...@bsd.com.br>: >> >>> Fala pessoal, >>> >>> >>>>> Sua indagação despertou em mim a curiosidade de saber como softwares como >>>>> fail2ban interagem com PF ou IPtables. >>>>> >>> De acordo com o site oficial... >>> >> >> Eu uso o BruteBlock para bloquear IPs que tentam fazer muito ssh >> e muito ftp, e obtém erros de conexão. Ele recebe do syslog as >> mensagens de erro, compara com uma regex, e coloca em uma >> table se passa de um número de tentativas em um determinado >> tempo. Mas no final de 2006 fiz um outro uso para ele. >> >> Eu fiz uma regex para verificar setup de conexão a uma porta TCP 25, >> e se tiver muitas tentativas em 1 minuto, ele coloca em uma table >> que é usada em uma regra que proíbe conexões SMTP. >> >> A quem interessar, eu posso mandar os arquivos de regras. >> >> >> João Rocha. >> >> >>> "Fail2ban scans log files like /var/log/pwdfail or >>> /var/log/apache/error_log and bans IP that makes too many password >>> failures. It updates firewall rules to reject the IP address." >>> >>> Achei bem legal... não conhecia essa ferramenta... =P >>> >>> Abraços, >>> -- >>> Davi Vercillo C. Garcia >>> http://www.google.com/profiles/davivcgarcia >>> >>> "Waste time in learning things that do not interest us, deprives us of >>> discovering interesting things." >>> - Carlos Drummond de Andrade >>> ------------------------- >>> Histórico: http://www.fug.com.br/historico/html/freebsd/ >>> Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd >>> >>> >> >> >> >> > > ------------------------- > Histórico: http://www.fug.com.br/historico/html/freebsd/ > Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd > -- "Sempre se apanha mais com as menores besteiras. Experiência própria." goffr...@gmail.com ------------------------- Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd