#!/usr/bin/perl # # # use Time::Local; use Term::ANSIColor; use POSIX qw(strftime); open(IN,"test"); my $actdate = strftime "%H:%d:%m:%M", localtime; my $acthour = strftime "%H",localtime; my $actmonth = strftime "%d",localtime; my $actday = strftime "%m",localtime; my $actmin = strftime "%M",localtime; while( $line = ){ if ( $line =~ /^#./ ){ } elsif ( $line =~ /^[1-9]/ ) { ($IP,$MAC,$MINI,$MAXI,$VIRUS,$FULL,$BUN,$NAME,$DATA) = split(/\ /,$line); ($HH,$ZZ,$MM,$Min) = split(/:/, $DATA); chomp($DATA); my $comm = "/sbin/iptables-save | /bin/grep $IP | /bin/grep DNAT >/dev/null 2>&1"; my $comI = "/sbin/iptables -t nat -I PREROUTING -i eth1 -m tcp -p tcp --dport 8080 -j DNAT --to-destination 10.0.0.251:80 -s "; my $comD = "/sbin/iptables -t nat -D PREROUTING -i eth1 -m tcp -p tcp --dport 8080 -j DNAT --to-destination 10.0.0.251:80 -s "; if ( $actdate eq $DATE) { $check = system($comm); chomp($check); if ( $check == 0 ) { system("$comD $IP"); system("$comI $IP"); } else { system("$comI $IP"); } } else { $check = system($comm); chomp($check); if ( $check == 0 ) { system("$comD $IP"); } else { print "$NAME ok\n"; } } } } #### else { $check = system($comm); chomp($check); if ( $check == 0 ) { system("$comD $IP"); } else { print "$NAME ok\n"; }