4 231
modifications
Ligne 30 : | Ligne 30 : | ||
<pre> | <pre> | ||
#! /bin/sh | #! /bin/sh | ||
banned_file=/root/iptables/banned.list | |||
me=`dirname $0`/ | me=`dirname $0`/ | ||
Ligne 36 : | Ligne 38 : | ||
iptables -N morales | iptables -N morales | ||
iptables -A INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,ftps-data,http,https,pop3,pop3s,imap,imaps,submission -j morales | iptables -A INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,ftps-data,http,https,pop3,pop3s,imap,imaps,submission -j morales | ||
if [ -f "$ | if [ -f "$banned_file" ]; then | ||
for ligne in `cat $ | for ligne in `cat $banned_file`; do | ||
iptables -A morales -s $ligne -j DROP | iptables -A morales -s $ligne -j DROP | ||
done | done | ||
else | else | ||
touch $ | touch $banned.list | ||
fi | fi | ||
echo "Started" | echo "Started" | ||
Ligne 65 : | Ligne 67 : | ||
iptables -A morales -s $2 -j DROP | iptables -A morales -s $2 -j DROP | ||
if [ "$?" = "0" ]; then | if [ "$?" = "0" ]; then | ||
echo $2 >> $ | echo $2 >> $banned_list | ||
echo "Added $2" | echo "Added $2" | ||
exit 0 | exit 0 | ||
Ligne 81 : | Ligne 83 : | ||
iptables -D morales -s $2 -j DROP | iptables -D morales -s $2 -j DROP | ||
if [ "$?" = "0" ]; then | if [ "$?" = "0" ]; then | ||
sed /$2/d $ | sed /$2/d $banned_list > $banned_list".tmp" | ||
mv $ | mv $banned_list".tmp" $banned_list | ||
echo "Removed $2" | echo "Removed $2" | ||
exit 0 | exit 0 | ||
Ligne 93 : | Ligne 95 : | ||
flush) | flush) | ||
iptables -F morales | iptables -F morales | ||
rm -f $ | rm -f $banned_list | ||
touch $ | touch $banned_list | ||
echo "ok" | echo "ok" | ||
exit 0 | exit 0 |