Guest User

Untitled

a guest
Apr 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php function getMac ( $Ip) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $output = shell_exec("nbtstat -a $Ip"); $output = explode("\n",$output); $mac_line = explode ("=", $output[ sizeof($output)-3 ]); $sMacAddress = trim($mac_line[1]); } else { $location = `which arp`; $arpTable = `$location \n $Ip`; $arpSplitted = split("\n",$arpTable);
  2.  
  3. foreach ($arpSplitted as $value) {
  4.  
  5. $valueSplitted = split(" ",$value);
  6.  
  7. foreach ($valueSplitted as $spLine) {
  8.  
  9. if (preg_match("/$Ip/",$spLine)) { reset($valueSplitted);
  10.  
  11. foreach ($valueSplitted as $spLine) { if (preg_match("/[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f]/i",$spLine)) { $sMacAddress = $spLine; break; } } } } }
  12.  
  13. } return $sMacAddress; } print getmac($REMOTE_ADDR); ?>
Add Comment
Please, Sign In to add comment