- 论坛徽章:
- 0
|
#!/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");
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31548/showart_1097666.html |
|