4 231
modifications
Ligne 40 : | Ligne 40 : | ||
case "$1" in | case "$1" in | ||
start) | start) | ||
iptables -N morales | /sbin/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 | /sbin/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 "$banned_file" ]; then | if [ -f "$banned_file" ]; then | ||
for ligne in `cat "$banned_file"`; do | for ligne in `cat "$banned_file"`; do | ||
iptables -A morales -s $ligne -j DROP | /sbin/iptables -A morales -s $ligne -j DROP | ||
done | done | ||
else | else | ||
Ligne 53 : | Ligne 53 : | ||
;; | ;; | ||
stop) | stop) | ||
iptables -F morales | /sbin/iptables -F morales | ||
iptables -D INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,ftps-data,http,https,pop3,pop3s,imap,imaps,submission -j morales | /sbin/iptables -D INPUT -p tcp -m multiport --dports ssh,telnet,ftp,ftp-data,ftps,ftps-data,http,https,pop3,pop3s,imap,imaps,submission -j morales | ||
iptables -X morales | /sbin/iptables -X morales | ||
if [ $quiet = 0 ]; then echo "Stoped"; fi | if [ $quiet = 0 ]; then echo "Stoped"; fi | ||
exit 0 | exit 0 | ||
Ligne 69 : | Ligne 69 : | ||
exit 1 | exit 1 | ||
fi | fi | ||
iptables -A morales -s $2 -j DROP | /sbin/iptables -A morales -s $2 -j DROP | ||
if [ "$?" = "0" ]; then | if [ "$?" = "0" ]; then | ||
echo "$2" >> "$banned_file" | echo "$2" >> "$banned_file" | ||
Ligne 85 : | Ligne 85 : | ||
exit 1 | exit 1 | ||
fi | fi | ||
iptables -D morales -s $2 -j DROP | /sbin/iptables -D morales -s $2 -j DROP | ||
if [ "$?" = "0" ]; then | if [ "$?" = "0" ]; then | ||
sed /$2/d "$banned_file" > "$banned_file".tmp | sed /$2/d "$banned_file" > "$banned_file".tmp | ||
Ligne 98 : | Ligne 98 : | ||
;; | ;; | ||
flush) | flush) | ||
iptables -F morales | /sbin/iptables -F morales | ||
rm -f "$banned_file" | rm -f "$banned_file" | ||
touch "$banned_file" | touch "$banned_file" | ||
Ligne 106 : | Ligne 106 : | ||
list) | list) | ||
echo "Currently banned ips :" | echo "Currently banned ips :" | ||
iptables -L morales | /sbin/iptables -L morales | ||
exit 0 | exit 0 | ||
;; | ;; |