![]() |
Debian 下防止arp病毒的perl脚本 |
#!/usr/bin/perl use strict; my $LocalIp="192.168.1.79"; my $file="/tmp/mac.txt"; system("sudo nmap -sP 192.168.1.0/24 > $file"); open(OLD,$file); my @content=;close OLD; open(NEW,">$file"); foreach my $con (@content) { if( $con =~ /Nmap/ig){$con="";} if( $con =~ /$LocalIp/ig){$con="";} if($con =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) { print "$1\.$2\.$3\.$4\t"; print NEW "$1\.$2\.$3\.$4\t"; } if($con =~ /(\w+)\:(\w+)\:(\w+)\:(\w+):(\w+):(\w+)/) { print "$1\:$2\:$3\:$4\:$5:$6\n"; print NEW "$1\:$2\:$3\:$4\:$5:$6\n"; } } close NEW; system("sudo arp -f $file"); |