Revisión 514
Añadido por Antonio J. Abasolo Sierra hace más de 11 años
deny_https | ||
---|---|---|
#! /bin/sh
|
||
#----------------------------------------------------------------------------------------
|
||
# Antonio J. Abasolo Sierra (Mayo-2010)
|
||
#----------------------------------------------------------------------------------------
|
||
# Controla la activación/desactivación de reglas iptables
|
||
# que cortan el tráfico https para todas las webs externas, e ips del centro
|
||
# que indiquemos en su fichero de configuración.
|
||
#
|
||
# Depende del fichero de configuración "/etc/network/deny_https".
|
||
#
|
||
# La regla "iptables-restore < /etc/network/iptables" se pone por seguridad:
|
||
# ya que se ejecuta tras eliminar las reglas, en cuyo momento la situación
|
||
# ya debería ser la misma que plantea esta línea.
|
||
#----------------------------------------------------------------------------------------
|
||
# Lista de web's https prohibidas para todos
|
||
www.tuenti.com
|
||
www.imo.im
|
||
www.badoo.com
|
||
www.twitter.com
|
||
www.hi5.com
|
||
www.suresome.com
|
||
www.bebo.com
|
||
www.ning.com
|
||
www.pornhub.com
|
||
|
||
#----------------------------------------------------------------------------------------
|
||
IPTABLES=/sbin/iptables
|
||
DENY_HTTPS=/etc/network/deny_https.conf
|
||
RED=`ifconfig | grep Bcast | cut -f2 -d: | awk '{print }' | cut -f1 -d.`
|
||
199.59.148.82
|
||
62.171.224.11
|
||
|
||
#iptables -A FORWARD -p tcp --dport 443 -d WEB -j DROP
|
||
#iptables -A FORWARD -p tcp --dport 443 -s IP -j DROP
|
||
|
||
# Bail out if no iptables binary or no configuration
|
||
[ -x ${IPTABLES} -a "$DENY_HTTPS" ] || exit 0
|
||
|
||
clear
|
||
|
||
#----------------------------------------------------------------------------------------
|
||
do_status() {
|
||
echo ""
|
||
echo "ESTADO ACTUAL DE LAS REGLAS ..."
|
||
echo "----------------------------------------------------"
|
||
$IPTABLES -L
|
||
echo "----------------------------------------------------"
|
||
}
|
||
|
||
#----------------------------------------------------------------------------------------
|
||
do_start() {
|
||
echo "ACTIVANDO reglas para controlar el tráfico https:"
|
||
echo "-------------------------------------------------"
|
||
iptables-restore < /etc/network/iptables
|
||
egrep -v '#|^$' $DENY_HTTPS | awk '{print $1}' | while read LINEA; do
|
||
if [ `echo $LINEA | grep $RED` ]; then OPCION="-s"; else OPCION="-d"; fi
|
||
echo " * Denegando https a $LINEA ..."
|
||
$IPTABLES -A FORWARD -p tcp --dport 443 $OPCION $LINEA -j REJECT 2> /dev/null
|
||
done
|
||
cortar_facebook
|
||
echo " ----------------------------------------------"
|
||
echo " * EL TRAFICO HTTPS ESTA RESTRINGIDO."
|
||
echo ""
|
||
}
|
||
|
||
do_stop() {
|
||
echo "DESACTIVANDO reglas para controlar el tráfico https:"
|
||
echo "-------------------------------------------------"
|
||
egrep -v '#|^$' $DENY_HTTPS | awk '{print $1}' | while read LINEA; do
|
||
if [ `echo $LINEA | grep $RED` ]; then OPCION="-s"; else OPCION="-d"; fi
|
||
echo " * Eliminando regla https para $LINEA ..."
|
||
$IPTABLES -D FORWARD -p tcp --dport 443 $OPCION $LINEA -j REJECT 2> /dev/null
|
||
done
|
||
echo " * Eliminando reglas https para facebook (rangos) ..."
|
||
iptables-restore < /etc/network/iptables
|
||
echo " -----------------------------------------------"
|
||
echo " * EL TRAFICO HTTPS ESTA LIBERADO."
|
||
echo ""
|
||
}
|
||
|
||
do_restart() {
|
||
do_stop
|
||
do_start
|
||
}
|
||
|
||
cortar_facebook() {
|
||
iptables -N FACEBOOK
|
||
|
||
echo " * Denegando https para facebook (rangos) ..."
|
||
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 66.220.144.0-66.220.159.255 --dport 443 -j FACEBOOK
|
||
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 69.63.176.0-69.63.191.255 --dport 443 -j FACEBOOK
|
||
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 69.171.0.0-69.171.242.255 --dport 443 -j FACEBOOK
|
||
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 184.50.162.0-184.50.162.255 --dport 443 -j FACEBOOK
|
||
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 204.15.20.0-204.15.23.255 --dport 443 -j FACEBOOK
|
||
|
||
iptables -A FACEBOOK -j REJECT
|
||
}
|
||
|
||
#----------------------------------------------------------------------------------------
|
||
case "$1" in
|
||
start)
|
||
do_start
|
||
# do_status
|
||
;;
|
||
stop)
|
||
do_stop
|
||
# do_status
|
||
;;
|
||
restart|force-reload)
|
||
do_restart
|
||
# do_status
|
||
;;
|
||
status)
|
||
do_status
|
||
;;
|
||
*)
|
||
echo "Usage: $0 {start|stop|restart|force-reload|status}"
|
||
exit 2
|
||
;;
|
||
esac
|
||
exit 0
|
||
#----------------------------------------------------------------------------------------
|
||
|
||
#facebook.com
|
||
#www.facebook.com
|
||
#www.meebo.com
|
Exportar a: Unified diff
limitar-https