Created
January 10, 2014 14:06
-
-
Save superchausette/8352755 to your computer and use it in GitHub Desktop.
A simple perl script using Net::MAC:Vendor to find vendors from ethernet MAC addresses in the ARP table.
On ubuntu you need this dependancy: libnet-mac-vendor-perl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Net::MAC::Vendor; | |
use strict; | |
open(ARP, "arp -n|") || die "Failed $!\n"; | |
my @arp_table; | |
while (<ARP>) { | |
if ($_ =~ m/incomplet/) {next;} | |
if ($_ =~ m/Address/) {next;} | |
my @line = split(' ',$_); | |
my $computer = {}; | |
$computer->{ip} = $line[0]; | |
$computer->{mac} = $line[2]; | |
$computer->{if} = $line[4]; | |
# Get vendor info | |
my $vendor_info = Net::MAC::Vendor::lookup( $computer->{mac} ); | |
$computer->{vendor} = $vendor_info->[0]; | |
push @arp_table , $computer; | |
} | |
print "ARP Table with vendors:\n"; | |
for my $i (0 .. $#arp_table) { | |
print "$arp_table[$i]{ip}\t"; | |
print "$arp_table[$i]{if}\t"; | |
print "$arp_table[$i]{mac}\t"; | |
print "$arp_table[$i]{vendor}"; | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment