welington27
(usa Debian)
Enviado em 03/05/2013 - 15:48h
Me diz pessoal como esta saindo esse script: Com esse firewall posso iniciar uma configuração segura?
#!/bin/bash
limpar(){
iptables -F
iptables -t nat -F
iptables -P FORWARD ACCEPT
echo 0 > /proc/sys/net/ipv4/ip_forward
}
IFEXT=eth0
IFINT=eth1
case $1 in
stop)
limpar
;;
start)
limpar
iptables -P FORWARD DROP
echo 1 > /proc/sys/net/ipv4/ip_forward
#--------------------------------------------------------------
echo " Bloqueando BackOriffice!!!"
iptables -A OUTPUT -p tcp --dport 1243 -j REJECT
iptables -A OUTPUT -p udp --dport 1243 -j REJECT
iptables -A OUTPUT -p tcp --dport 5800 -j REJECT
iptables -A OUTPUT -p tcp --dport 5801 -j REJECT
iptables -A OUTPUT -p tcp --dport 5900 -j REJECT
iptables -A OUTPUT -p tcp --dport 5901 -j REJECT
iptables -A OUTPUT -p tcp --dport 31337 -j REJECT
iptables -A OUTPUT -p tcp --dport 31338 -j REJECT
iptables -A OUTPUT -p tcp --dport 6000 -j REJECT
iptables -A OUTPUT -p tcp --dport 64320 -j REJECT
iptables -A OUTPUT -p udp --dport 64320 -j REJECT
iptables -A OUTPUT -p tcp --dport 26000 -j REJECT
iptables -A OUTPUT -p tcp --dport 8010 -j REJECT
iptables -A OUTPUT -p tcp --dport 6000 -j REJECT
iptables -A OUTPUT -p tcp --dport 6001 -j REJECT
iptables -A OUTPUT -p udp --dport 6001 -j REJECT
iptables -A OUTPUT -p tcp --dport 3306 -j REJECT
iptables -A OUTPUT -p udp --dport 161 -j REJECT
iptables -A OUTPUT -p udp --dport 111 -j REJECT
iptables -A OUTPUT -p tcp --dport 111 -j REJECT
iptables -A OUTPUT -p udp --dport 162 -j REJECT
iptables -A OUTPUT -p udp --dport 23 -j REJECT
iptables -A OUTPUT -p tcp --dport 111 -j REJECT
iptables -A OUTPUT -p tcp --dport 143 -j REJECT
echo "OH !!"
iptables -A OUTPUT -p tcp -o $IFEXT --dport 137 -j DROP
iptables -A OUTPUT -p udp -o $IFEXT --dport 137 -j DROP
iptables -A OUTPUT -p tcp -o $IFEXT --dport 138 -j DROP
iptables -A OUTPUT -p udp -o $IFEXT --dport 138 -j DROP
iptables -A OUTPUT -p udp -o $IFEXT --dport 139 -j DROP
iptables -A OUTPUT -p tcp -o $IFEXT --dport 139 -j DROP
iptables -A OUTPUT -p tcp -o $IFEXT --dport 445 -j DROP
iptables -A OUTPUT -p udp -o $IFEXT --dport 445 -j DROP
iptables -A OUTPUT -p tcp -o $IFEXT --dport 1512 -j DROP
iptables -A OUTPUT -p udp -o $IFEXT --dport 1512 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 6000 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 6000 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 137 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 137 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 138 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 138 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 139 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 139 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 445 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 445 -j DROP
iptables -A INPUT -p tcp -i $IFEXT --dport 1512 -j DROP
iptables -A INPUT -p udp -i $IFEXT --dport 1512 -j DROP
echo "OK :-) "
#--------------------------------------------------------------
echo "Bloqueando Pacotes TCP Mal Formados"
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -m state --state INVALID -j DROP
iptables -A FORWARD -m state --state INVALID -j DROP
echo "OK :-) "
#--------------------------------------------------------------
echo "Verifica Pacotes fragmentados na Rede"
iptables -N VALID_CHECK
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL SYN,ACK,FIN,URG -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP
echo "OK :-) "
#-----------------------------------------------------------------
echo "Protecao Contra ataque DOS"
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A OUTPUT -p tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
echo "OK :-) "
#--------------------------------------------------------------
echo "Liberando SMTP !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 25 -j ACCEPT
echo "OK :-)"
#----------------------------------------------------------------
echo "Proxy 3128"
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 3128 -j ACCEPT
echo "OK :-)"
#----------------------------------------------------------------
echo "Liberando DNS !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 53 -j ACCEPT
iptables -A INPUT -p udp -s 0/0 -d 0/0 --dport 53 -j ACCEPT
echo "OK :-)"
#---------------------------------------------------------------
echo "Bloqueando Bate papo Gmail!!! "
iptables -I INPUT -s chatenabled.mail.google.com -j DROP
iptables -A OUTPUT -d chatenabled.mail.google.com -j DROP
iptables -I FORWARD -s 0/0 -d chatenabled.mail.google.com -j DROP
#-----------------------------------------------------------------
echo "Liberando HTTPD !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 8000 -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 8080 -j ACCEPT
echo "OK :-)"
#-----------------------------------------------------------------
echo "Liberando POP3 !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 110 -j ACCEPT
echo "OK :-)"
#------------------------------------------------------------------
echo "Liberando WEB MAIL !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 143 -j ACCEPT
iptables -A INPUT -p udp -s 0/0 -d 0/0 --dport 143 -j ACCEPT
echo "OK :-)"
#-----------------------------------------------------------------
echo "Bloqueando SUNRPC !!! "
iptables -A INPUT -p tcp -s 0/0 -d 0/0 --dport 111 -j REJECT
echo "OK :-)"
#-------------------------------------------------------------------
echo "firewall executado as: $(date +%R:%F)" >> /root/nat.log
;;
*)
echo " Use: $(basename $0) {start|stop}"
;;
esac