Created
March 30, 2015 13:45
-
-
Save clarkwinkelmann/e0f67db7ac577d086c7d to your computer and use it in GitHub Desktop.
PHP Wrapper for arp-scan command
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
<?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