Skip to content

Instantly share code, notes, and snippets.

@clarkwinkelmann
Created March 30, 2015 13:45
Show Gist options
  • Save clarkwinkelmann/e0f67db7ac577d086c7d to your computer and use it in GitHub Desktop.
Save clarkwinkelmann/e0f67db7ac577d086c7d to your computer and use it in GitHub Desktop.
PHP Wrapper for arp-scan command
<?php
// Must be run as root
$arp_scan = shell_exec('arp-scan --interface=eth0 --localnet');
$arp_scan = explode("\n", $arp_scan);
$matches;
foreach($arp_scan as $scan) {
$matches = array();
if(preg_match('/^([0-9\.]+)[[:space:]]+([0-9a-f:]+)[[:space:]]+(.+)$/', $scan, $matches) !== 1) {
continue;
}
$ip = $matches[1];
$mac = $matches[2];
$desc = $matches[3];
echo "Found device with mac address $mac ($desc) and ip $ip\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment