#!/usr/bin/perl #written by Shunsuke Sakai(2000/06/06) &dateget; ############ get the IP address and MAC address ############## $/="}\n"; $\="\n"; open(LOG,'){ @log=split(/\n/,$log); @log[3]=~ s/\shardware\sethernet\s//; @log[3]=~ s/;//; @ip=split(/ +/,@log[0]); @date=split(/ +/,@log[2]); $lease{@log[3]}=@ip[1]; $lease2{@log[3]}=@date[2]; } ############## get the authorized MAC address ############### $/="\n"; open(CLIENT,'){ chop $client; if($client=~ m/[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a- f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f]/){ @client=(@client,$client); } } ############## check the unauthorized MAC address ############### open(LOG,'>/var/dhcp/dhcp.unauth'); $regist = 'no'; foreach $address (keys %lease){ foreach $client (@client){ if($address eq $client){ $regist = 'yes'; } } if($regist ne 'yes'){ $number = $number +1; print LOG $lease{$address},' - ',$lease2{$address},' - ',$addres s; } $regist = 'no'; } print LOG "\n",$number,' persons are unauthorized !!','(',$year,'/',$month,'/',$ today,')'; close(LOG); close(CLIENT); close(LOG); ############### get the yesterday's date ############################ sub dateget{ system('date "+%Y %m %d" > /var/log/ftp/datefile'); open(DATE,"< /var/log/ftp/datefile"); while($date=){ chop $date; @line=split(/ +/,$date); $year=$line[0]; $month=$line[1]; $today=$line[2]; } close(DATE); }