Script contra ataques de Brutal Force por SSH.
Publicado por Silvio Soares da Silva Junior 01/10/2005
[ Hits: 7.918 ]
Este script bloqueia os ips que tentaram invadir seu servidor por SSH
#!/bin/bash
#Script Criado por Mastah
#Alterado por Silvio Junior
MODE="AUTO"
#MODE="MANUAL"
if [ -f /var/log/messages ] ; then
ips=$(cat -n /var/log/messages | grep -P "(Invalid)" | grep -i sshd | awk -F" " '{ print $11}')
attempts=1
for ip in $ips ; do
lastip=$ip
if [ "$lastip" == "$ip" ] ; then
attempts=$(expr $attempts + 1)
if [ $attempts -ge 5 ] ; then
echo "Brute force SSHD attack detected from $ip"
attempts=1
lastip=""
blocked=$(iptables -L INPUT | grep -i $ip | grep -i DROP)
if [ "$blocked" ] ; then
echo "> Ip Already Blocked. Continuing with scan"
echo " "
else
if [ $MODE == "MANUAL" ] ; then
echo "> Do You Want to add this IP to INPUT DROP in IPTABLES rules? (y/n)"
read resp
if [ "$resp" == "y" ] ; then
iptables -A INPUT -s $ip -j DROP
echo "> IP $ip ADDED TO IPTABLES INPUT DROP ruleset"
echo " "
fi
else
iptables -A INPUT -s $ip -j DROP
echo "> IP $ip ADDED TO IPTABLES INPUT DROP ruleset"
echo " "
fi
fi
fi
fi
done
fi
Enviar mensagens Via Net Send no Linux
Script de Instalação de Layer7 no CentOS 6.0
Manipulação de contas de email com o postfix
Vale a pena ter mais de uma interface grafica no seu Linux?
Estrutura e Funcionamento de um Ebuild no Gentoo Linux
Instalação e Configuração do Void com Cinnamon
Montagem pré automática de HD externo usb em NTFS não funciona no Debian Trixie - Solução
Guia de instalação do Gentoo Linux com Cinnamon (UEFI, LUKS2, Btrfs)









