
desv.paulo
(usa Slackware)
Enviado em 20/03/2010 - 10:21h
Bom dia pessoal,
achei o seguinte script na net para bloquear o force brute:
#!/bin/bash</code>
cp /etc/hosts.deny /var/tmp/hosts.deny
# Jun 8 00:39:43 mintaka sshd[23332]: User root from 222.77.183.51 not allowed because not listed in AllowUsers
egrep "$(date +%b) ($(date +%d)|$(date +%e)).*User .* from [a-z0-9\.]* not allowed because not listed in AllowUsers" /var/log/messages | sed -e 's/.* from \([a-z0-9\.]*\) .*/\1/' | sort | uniq | sed -e 's/^/ALL:/' > /etc/hosts.deny ;
#Jun 8 11:54:33 mintaka sshd[31221]: Invalid user bob from 62.204.145.224
egrep "$(date +%b) ($(date +%d)|$(date +%e)).*Invalid user .* from [a-z0-9\.]*$" /var/log/messages | sed -e 's/.*Invalid user .* from//' | sort | uniq | sed -e 's/^/ALL:/' >> /etc/hosts.deny ;
diff -u /etc/hosts.deny /var/tmp/hosts.deny &>/dev/null || (echo "** hosts.deny updated **" ; cat /etc/hosts.deny)
Só que me retorno o erro:
bloqueio-hosts.sh: line 6: gt: command not found
/etc/hosts.deny: line 5: http-rman: command not found
bloqueio-hosts.sh: line 8: syntax error near unexpected token `&'
bloqueio-hosts.sh: line 8: `egrep "$(date +%b) ($(date +%d)|$(date +%e)).*Invalid user .* from [a-z0-9\.]*$" /var/log/messages | sed -e 's/.*Invalid user .* from//' | sort | uniq | sed -e 's/^/ALL:/' >> /etc/hosts.deny ;'
Alguem pode me ajudar ?