Script contra ataques de Brutal Force por SSH.
Publicado por Silvio Soares da Silva Junior 01/10/2005
[ Hits: 7.699 ]
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
Baixando e instalando o Asterisk
Script de Instalação de Layer7 no CentOS 6.0
Compartilhando a Internet com Iptables
Debian - inicializando VMs (VirtualBox) no boot
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
Quebra de linha na data e hora no Linux Mint
Organizando seus PDF com o Zotero
tentando instalar em um notebook antigo o Linux LegacyOS_2023... [RESO... (9)
Problema com Conexão Outlook via Firewall (OpenSUSE) com Internet Fibr... (5)