Saturday, June 13, 2009

Net::ARP Checking a Mac address with perl

So net::arp Creates arp packets. The intention of this script was to check for the mac address of a remote machine, however after a little experimentation I realized the function was only checking the arp table. Which is not what this was intended for so....le sigh. However it might be handy for someone to check the arp table in perl, this would be convenient. It would also be nice if you did some sort of arp or ping scan before using it. BEWARE OF BOTH SCANS. Either are likely to set of an IDS or IPS, however a ping scan is always the more obnoxious of the two.

Caveat: You need Net::ARP installed for this to work:
sudo cpan
install Net::ARP

use Net::ARP;

$targetOne = "";
$dev = "eth0";
my $mac = Net::ARP::arp_lookup($dev, $targetOne);
print "The Mac address is $mac\n";

If you liked this, you will probably also like these two:

ps the command to check the arp table is arp -a

Caveat: I was not able to get Net::ARP to install cleanly on my mac from CPAN, so I used Fedora. I don't really think this says anything about Net::ARP as 90 percent of CPAN packages tend to be a pain in my ass on my mac.

No comments: