shieldscript - Script para defesa b醩ica do seu GNU/Linux
Publicado por Felipe Ruiz Peixoto (鷏tima atualiza玢o em 07/04/2015)
[ Hits: 4.108 ]
Homepage: https://www.ubuntu.com/
Download 1427907799.shieldscript (vers鉶 2)
Olá, uma das coisas que mais gosto de fazer em um GNU/Linux são scripts, eles facilitam muito a minha vida. :)
Acabei de criar um script para configurar uma proteção básica para meu sistema (Kali). Ele pode ser útil para pessoas que não possuem muito conhecimento em GNU/Linux a fim de se protegerem.
Estou publicando o script aqui para que seja melhorado por quem tiver mais ideias. Vou colocar ele no SourceForge também.
Precisa ter iptables e xterm instalado, e ser executado como superusuário.
Ele instala automaticamente vários pacotes: clamav-daemon, clamav-freshclam, clamtk (não usa), rkhunter, chkrootkit e firestarter (não usa). Veja a seguir um manual de como utilizar o script.
Para começar, abra o terminal, digite o comando su e depois sua senha para usar como superusuário.
Depois é só arrastar e soltar o arquivo para dentro do terminal (ou digitar o caminho até ele) e apertar enter para ver as opções:
Para instalar, use:
# /minhapasta/shieldscript -i
O terminal poderá fazer "uma ou duas" perguntas, uma delas é "Type your net ip (example 123.456.789.123/16):". Então você deve ver qual faixa de IP seu roteador utiliza e colocar aqui no formato mostrado no exemplo. Para facilitar, abra as informações da conexão clicando com o botão direto no ícone de rede perto do relógio. Para o número antes da barra procure sua máscara de sub-rede e troque os números 255 pelos números do seu endereço IP, deixando outros números como estão. Para o número depois da barra, conte quantos números 255 tem sua máscara e multiplique isto por 8. Este método não é correto mas funciona para redes domésticas simples.
No fim da instalação este script vai criar outro chamado "start_my_firewall" que deve ser executado sempre que você fizer seu login, bastando dar dois cliques sobre ele.
Para atualizar os programas de proteção use:
# /minhapasta/shieldscript -u
Para instalar e atualizar em seguida use:
# /minhapasta/shieldscript -iu
Para procurar e remover programas maliciosos do seu sistema e ativar o firewall use:
# /minhapasta/shieldscript -c
Para fazer isso depois de instalar e atualizar use:
# /minhapasta/shieldscript -a
Para "zerar" as configurações de firewall use:
# /minhapasta/shieldscript -f
E para desinstalar tudo use:
# /minhapasta/shieldscript -r
Vers鉶 2 - Enviado por Felipe Ruiz Peixoto em 01/04/2015
Changelog: Nova vers鉶 melhorada.
Download 1427907799.shieldscript
#!/bin/bash
#牋This program is free software; you can redistribute it and/or modify
#牋it under the terms of the GNU General Public License as published by
#牋the Free Software Foundation; either version 2 of the License, or
#牋(at your option) any later version.
#
#牋This program is distributed in the hope that it will be useful,
#牋but WITHOUT ANY WARRANTY; without even the implied warranty of
#牋MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.牋See the
#牋GNU General Public License for more details.
#
#牋You should have received a copy of the GNU General Public License
#牋along with this program; if not, write to the Free Software
#牋Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#牋MA 02110-1301, USA.
#
## Version number of the script
VERSION=0.3
echo Shieldscript-Anti Hacker Linux Script provides basic protection configuration v. $VERSION
echo Need superuser permissions
## Installation function
Install(){
牋牋echo Installing needed packages
牋牋apt-get install --fix-missing -y clamav-daemon clamav-freshclam clamtk rkhunter chkrootkit firestarter
牋牋echo Blocking the ping in the firewall
牋牋iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
牋牋echo Blocking port scanners
牋牋iptables -A INPUT -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
牋牋iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
牋牋echo Blocking tracertroute
牋牋iptables -A INPUT -p udp -s 0/0 -i eth1 --dport 33435:33525 -j DROP
牋牋echo Protecting against attacks, worms and tojans
牋牋iptables -A INPUT -m state --state INVALID -j DROP
牋牋iptables -A FORWARD -p tcp --dport 135 -i venet0 -j REJECT
牋牋iptables -N TROJAN
牋牋iptables -A TROJAN -m limit --limit 15/m -j LOG --log-level 6 --log-prefix "FIREWALL: trojan: "
牋牋iptables -A TROJAN -j DROP
牋牋iptables -A INPUT -p TCP -i venet0 --dport 666 -j TROJAN
牋牋iptables -A INPUT -p TCP -i venet0 --dport 4000 -j TROJAN
牋牋iptables -A INPUT -p TCP -i venet0 --dport 6000 -j TROJAN
牋牋iptables -A INPUT -p TCP -i venet0 --dport 6006 -j TROJAN
牋牋iptables -A INPUT -p TCP -i venet0 --dport 16660 -j TROJAN
牋牋echo Avoiding IP Spoofing in the firewall
牋牋echo 'Type your net ip (example 123.456.789.123/16):'
牋牋read faixadeip
牋牋#Bloqueia IP Spoofing para máquinas com interface de rede
牋牋#iptables -A INPUT -s 10.0.0.0/8 -i eth0 -j DROP
牋牋#iptables -A INPUT -s 172.16.0.0/8 -i eth0 -j DROP
牋牋#iptables -A INPUT -s 192.168.0.0/8 -i eth0 -j DROP
牋牋iptables -A FORWARD -i eth0 ! -s $faixadeip -j DROP
牋牋#Bloqueia IP Spoofing para máquinas com interface WiFi:
牋牋#iptables -A INPUT -s 10.0.0.0/8 -i wlan0 -j DROP
牋牋#iptables -A INPUT -s 172.16.0.0/8 -i wlan0 -j DROP
牋牋#iptables -A INPUT -s 192.168.0.0/8 -i wlan0 -j DROP
牋牋iptables -A FORWARD -i wlan0 ! -s $faixadeip -j DROP
牋牋#Bloqueia IP Spoofing para máquinas com interface com modens ADSL:
牋牋#iptables -A INPUT -s 10.0.0.0/8 -i ppp0 -j DROP
牋牋#iptables -A INPUT -s 172.16.0.0/8 -i ppp0 -j DROP
牋牋#iptables -A INPUT -s 192.168.0.0/8 -i ppp0 -j DROP
牋牋iptables -A FORWARD -i ppp0 ! -s $faixadeip -j DROP
牋牋#Garante a navegacao da maquina
牋牋#iptables -A INPUT -m state -state RELATED,ESTABLISHED -j ACCEPT
牋牋echo Saving firewall configurations and changing the rc.local
牋牋mkdir -p /usr/share/shieldscript
牋牋echo Making backup of your current rc.local, to restore use the option -f
牋牋cp -f -R /etc/rc.local /usr/share/shieldscript
牋牋chmod +x /usr/share/shieldscript/rc.local
牋牋echo Saving your firewall settings
牋牋iptables-save > /usr/share/shieldscript/conf
牋牋echo Making the script to enable firewall settings
牋牋echo '#!/bin/sh' > /usr/share/shieldscript/firescript
牋牋echo "echo Shieldscript v. $VERSION" >> /usr/share/shieldscript/firescript
牋牋echo "echo To activate your firewall please input your superuser password" >> /usr/share/shieldscript/firescript
牋牋echo 'su -c "iptables-restore /usr/share/shieldscript/conf"' >> /usr/share/shieldscript/firescript
牋牋echo "echo OK" >> /usr/share/shieldscript/firescript
牋牋echo "echo Press enter to exit" >> /usr/share/shieldscript/firescript
牋牋echo "read none" >> /usr/share/shieldscript/firescript
牋牋echo "exit 0" >> /usr/share/shieldscript/firescript
牋牋chmod +x /usr/share/shieldscript/firescript
牋牋## Create a script to start the firewall
牋牋echo '#!/bin/sh' > start_my_firewall
牋牋echo 'xterm -e /usr/share/shieldscript/firescript' >> start_my_firewall
牋牋chmod +x start_my_firewall
牋牋## TODO Start firescript at logon
牋牋#echo Creating shieldscriptfw in init.d to start the firewall
牋牋#echo '#!/bin/bash' > /etc/init.d/shieldscriptfw
牋牋#echo '#' >> /etc/init.d/shieldscriptfw
牋牋#echo '# /etc/init.d/shieldscriptfw' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo '### BEGIN INIT INFO' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Provides:牋牋牋牋牋shieldscriptfw' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Required-Start:牋牋$local_fs $syslog' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Required-Stop:牋牋 $local_fs $syslog' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Default-Start:牋牋 2 3 4 5' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Default-Stop:牋牋牋0 1 6' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Short-Description: Start shieldscript firewall configuration automatically' >> /etc/init.d/shieldscriptfw
牋牋#echo '# Description:牋牋牋 Start shieldscript firewall configuration' >> /etc/init.d/shieldscriptfw
牋牋#echo '### END INIT INFO' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo 'case "$1" in' >> /etc/init.d/shieldscriptfw
牋牋#echo 'start ) xterm /usr/share/shieldscript/firescript ;;' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo 'stop ) echo "OK." ;;' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo 'restart )echo "OK." ;;' >> /etc/init.d/shieldscriptfw
牋牋#echo ' ' >> /etc/init.d/shieldscriptfw
牋牋#echo '* ) echo "Invalid option" ;;' >> /etc/init.d/shieldscriptfw
牋牋#echo 'esac' >> /etc/init.d/shieldscriptfw
牋牋#chmod +x /etc/init.d/shieldscriptfw
牋牋#which update-rc.d
牋牋#if [ $? = 0 ]
牋牋#then
牋牋#牋 update-rc.d shieldscriptfw defaults
牋牋#else
牋牋#牋 chkconfig --add shieldscriptfw
牋牋#牋 chkconfig shieldscriptfw on
牋牋#fi
牋牋#echo '#!/bin/sh -e' > /etc/rc.local
牋牋#echo '# rc.local' >> /etc/rc.local
牋牋#echo '#' >> /etc/rc.local
牋牋#echo '# This script is executed at the end of each multiuser runlevel.' >> /etc/rc.local
牋牋#echo '# Make sure that the script will "exit 0" on success or any other' >> /etc/rc.local
牋牋#echo '# value on error.' >> /etc/rc.local
牋牋#echo '#' >> /etc/rc.local
牋牋#echo '# In order to enable or disable this script just change the execution' >> /etc/rc.local
牋牋#echo '# bits.' >> /etc/rc.local
牋牋#echo '#' >> /etc/rc.local
牋牋#echo '# By default this script does nothing.' >> /etc/rc.local
牋牋#echo '# Shieldscript firewall' >> /etc/rc.local
牋牋#echo "xterm /usr/share/shieldscript/firescript" >> /etc/rc.local
牋牋#echo 'exit 0' >> /etc/rc.local
牋牋#chmod +x /etc/rc.local
牋牋echo INSTALLATION FINISHED
}
Update(){
牋牋rkhunter --update
牋牋freshclam
}
FirewallReset(){
牋牋iptables -F
牋牋iptables -Z
牋牋iptables -X
牋牋mv /usr/share/shieldscript/rc.local牋/etc
牋牋chmod +x /etc/rc.local
牋牋rm -R /usr/share/shieldscript
牋牋echo Use a opcao -i para refazer o firewall
牋牋# iptables -P INPUT ACCEPT
牋牋# iptables -F
牋牋# iptables -A INPUT -i lo -j ACCEPT
牋牋# iptables -A INPUT -m state 杝tate ESTABLISHED,RELATED -j ACCEPT
牋牋# iptables -A INPUT -p tcp 杁port 22 -j ACCEPT
牋牋# iptables -P INPUT DROP
牋牋# iptables -P FORWARD DROP
牋牋# iptables -P OUTPUT ACCEPT
牋牋# iptables -L -v
}
Uninstall(){
牋牋FirewallReset
牋牋apt-get remove --fix-missing -y clamav-daemon clamav-freshclam clamtk rkhunter chkrootkit firestarter
牋牋rm -f -R /usr/share/shieldscript
牋牋#which update-rc.d
牋牋#if [ $? = 0 ]
牋牋#then
牋牋#牋 update-rc.d -f shieldscriptfw remove
牋牋#else
牋牋#牋 chkconfig shieldscriptfw off
牋牋#牋 chkconfig --del shieldscriptfw
牋牋#fi
牋牋#rm -f /etc/init.d/shieldscriptfw
牋牋echo Shieldscript v. $VERSION uninstalled
}
Check(){
牋牋rkhunter --check
牋牋chkrootkit
牋牋clamscan --bell --remove=yes -r -z -i
牋牋iptables-restore /usr/share/shieldscript/conf
}
Help(){
牋牋echo Syntax: anti-hacker-linux-script [option]
牋牋echo Options:
牋牋echo -i牋 ----牋 install
牋牋echo -u牋 ----牋 update
牋牋echo -c牋 ----牋 check the system
牋牋echo -iu牋----牋 install and update
牋牋echo -a牋 ----牋 install, update and check
牋牋echo -r牋 ----牋 uninstall
牋牋echo -h牋 ----牋 show this help text
牋牋echo -f牋 ----牋 reset firewall
牋牋echo -x牋 ----牋 exit
牋牋## Authors
牋牋echo 'Felipe Ruiz Peixoto "Felipeludo" <feliperuiz.sax.eletronic@gmail.com>'
}
case $1 in
牋牋"-h") Help ;;
牋牋"-u") Update ;;
牋牋"-c") Check ;;
牋牋"-i") Install ;;
牋牋"-iu") Install ; Update ;;
牋牋"-a") Install ; Update ; Check ;;
牋牋"-r") Uninstall ;;
牋牋"-f") FirewallReset ;;
牋牋"-x") exit 0 ;;
牋牋*) Help ;;
esac
Automatizar a importa玢o de chave privada GPG (GnuPG)
Gravar uma imagem ISO em um CD-R
imdb-cli - consultar filmes, s閞ies e atores pelo site IMDB no terminal
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o s醔ado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Novos apps de produtividade, avan鏾s em IA e distros em ebuli玢o agitam o universo Linux
Como instalar o reposit髍io do DBeaver no Ubuntu
Como instalar o Plex Media Server no Ubuntu
Digitando underscore com "shift" + "barra de espa鏾s"
Como ativar a lixeira e recuperar aquivos deletados em um servidor Linux
Como mudar o nome de dispositivos Bluetooth via linha de comando
Programa fora de escala na tela do pc (22)
Problemas com Driver NVIDIA (1)
Fedora KDE plasma 42 X M骴ulo de seguran鏰 BB (Warsaw-2) (1)









