Mudanças entre as edições de "Bloqueando IPs listados no Logwatch"
De MochilaWiki
Ir para navegaçãoIr para pesquisarLinha 1: | Linha 1: | ||
gerando relatório do dia | gerando relatório do dia | ||
− | + | <source lang="bash"> | |
+ | logwatch -range=Today -service=http -filename - > /tmp/logwatch | ||
+ | </source> | ||
+ | |||
+ | gerando relatório da semana | ||
+ | <source lang="bash"> | ||
+ | logwatch -range="between -7 days and -1 days" -service=http -filename - > /tmp/logwatch | ||
+ | </source> | ||
extraindo ip da lista do Logwatch | extraindo ip da lista do Logwatch | ||
− | + | <source lang="bash"> | |
+ | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' /tmp/logwatch | sort | uniq > crackers.txt | ||
+ | </source> | ||
criando regra no iptables para bloquear os IPs | criando regra no iptables para bloquear os IPs | ||
− | + | <source lang="bash"> | |
+ | sed 's/.*/iptables -A INPUT -s & -j DROP/' crackers.txt > firewall.sh | ||
+ | </source> | ||
rodando o script gerado | rodando o script gerado | ||
− | + | <source lang="bash"> | |
+ | bash firewall.sh | ||
+ | </source> | ||
salvando ajuste no iptables para iniciar no boot | salvando ajuste no iptables para iniciar no boot |
Edição das 14h24min de 5 de dezembro de 2015
gerando relatório do dia
logwatch -range=Today -service=http -filename - > /tmp/logwatch
gerando relatório da semana
logwatch -range="between -7 days and -1 days" -service=http -filename - > /tmp/logwatch
extraindo ip da lista do Logwatch
grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' /tmp/logwatch | sort | uniq > crackers.txt
criando regra no iptables para bloquear os IPs
sed 's/.*/iptables -A INPUT -s & -j DROP/' crackers.txt > firewall.sh
rodando o script gerado
bash firewall.sh
salvando ajuste no iptables para iniciar no boot
Baseado em