windows XP 获取网卡MAC和IP地址
[*] 程序源码
use strict;
open my $fh,"ipconfig /all|" or die "can't find cmd ipconfig /all:$!";
my (%mac_ip_hash, $ip_address, $mac_address);
while(defined(my $line1=<$fh>)){
if ($line1 =~ /^Windows/){
print "Windows IP Configure:\n"
};
if ($line1 =~ /(-----)+?/)
{
#print $1."\n";
$mac_address = $1;
};
if ($line1 =~ /(IP.*)(\s+)((25|2|{1}{2}|{1}{1}|)\.(25|2|{1}{2}|{1}{1}||0)\.(25|2|{1}{2}|{1}{1}||0)\.(25|2|{1}{2}|{1}{1}|))/){
#print $3."\n";
$ip_address = $3;
$mac_ip_hash{$mac_address}=$ip_address;
};
}
while(my ($key, $value) = each %mac_ip_hash){
print "$key => $value\n";
}
2.程序输出:
C:\>perl ip_mac.pl
Windows IP Configure:
00-23-8B-75-ED-5F => 192.168.0.37
页:
[1]