Mostrando entradas con la etiqueta kmp. Mostrar todas las entradas
Mostrando entradas con la etiqueta kmp. Mostrar todas las entradas

jueves, 14 de junio de 2012

Iptables - Bloquear por String


Iptables - Bloquear por String

iptables -I  FORWARD -i vlan110 -p tcp --dport 443 -m string --string
"facebook" --algo kmp -j DROP


# iptables -nvL
Chain FORWARD (policy DROP 433 packets, 149K bytes)
 pkts bytes target     prot opt in     out     source
destination
   0     0 DROP       tcp  --  vlan110 *       0.0.0.0/0
0.0.0.0/0           tcp dpt:443 STRING match "facebook" ALGO name bm
TO 65535

Esto funciona de esta manera:

si el usuario busca "facebook" en https://google.com.ar encuentra y
accede a todo lo que este permitido.
por ejemplo

webtomich.com.ar/?tag=facebook

que es el quinto elemento mostrado en esa búsqueda.

Ahora, si el usuario tiene su facebook para conectarse automáticamente
al abrir el sitio, esta acción procede y se logea pero no puede ver el
contenido multimedia que esta bloqueado en el squid.


http://wiztelsys.com/Article_iptables_bob2.html
http://rhcelinuxguide.wordpress.com/2008/08/05/iptables-string-match-to-drop-malicious-urls/




System Requirements.

Preferred kernel version : 2.6.18 or later.
The iptables program(1.3.5 or later) installed on your machine.
The kernel should be compiled with string matching support. To do this, the following line should be added to the .config file prior to compiling the kernel:
CONFIG_NETFILTER_XT_MATCH_STRING=m

cat /proc/modules|grep xt_string

iptables -I INPUT -p tcp --dport 25 -m string --string "Subject" --algo bm -j DROP
**Do it now with an optimised rule!

The same rule might be modified to one with less overhead (that is, it uses less resources) by limiting the search specifying offset values, and by assuming that the SMTP subject header will be within an offset limit of 15000 in the packet.
iptables -I INPUT -p tcp --dport 25 -m string --string "Subject"  --algo bm --to 15000 -j DROP

miércoles, 23 de mayo de 2012

Iptables - bloquear Torrent

http://www.adminsehow.com/2011/04/block-bittorrent-traffic-on-your-linux-firewall-using-iptables/

Bloquear torrents con iptables

iptables -N DROPTORRENT > /dev/null 2> /dev/null
iptables -F DROPTORRENT
iptables -A DROPTORRENT -j LOG --log-prefix "DROPTORRENT "
iptables -A DROPTORRENT -j DROP

#Torrent
iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "torrent" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "announce" -j DROPTORRENT
iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROPTORRENT

# DHT keyword
iptables -A FORWARD -m string --string "get_peers" --algo bm -j DROPTORRENT
iptables -A FORWARD -m string --string "announce_peer" --algo bm -j DROPTORRENT
iptables -A FORWARD -m string --string "find_node" --algo bm -j DROPTORRENT