Skip to content

Instantly share code, notes, and snippets.

@superchausette
Created January 10, 2014 14:06
Show Gist options
  • Save superchausette/8352755 to your computer and use it in GitHub Desktop.
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
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