A Digital Age Deserves A Digital Leader

req. MAC. PHP Debuging???

req. MAC. PHP Debuging???

Postby c0ldfyr3 » Mon Aug 25, 2008 3:20 pm

okay so i need to gain the users MAC address and display it for them. ( IP address's are too easy, and not so personal ).. I have a hacker on one of my sites that is using my site for phishing, so i want to add a nice little feature to his application before i remove it. i have set it so that page can only be viewed, everything is locked. But i want to get the creators IP, Host name, and MAC address.. does this code look good, or is there anything i should fix in there?

Code: Select all

function returnmacAddress() {
// This code is under the GNU Public Licence

// Get the arp executable path
$location = `which arp`;
$location = rtrim($location);

// Execute the arp command and store the output in $arpTable
$arpTable = `$location -a`;

// Split the output so every line is an entry of the $arpSplitted array
$arpSplitted = split("\n",$arpTable);

// Get the remote ip address (the ip address of the client, the browser)
$remoteIp = $GLOBALS['REMOTE_ADDR'];
$remoteIp = str_replace(".", "\\.", $remoteIp);

// Cycle the array to find the match with the remote ip address
foreach ($arpSplitted as $value) {
   // Split every arp line, this is done in case the format of the arp
   // command output is a bit different than expected
   $valueSplitted = split(" ",$value);
   foreach ($valueSplitted as $spLine) {
      if (preg_match("/$remoteIp/",$spLine)) {
      $ipFound = true;
      }
      // The ip address has been found, now rescan all the string
      // to get the mac address
      if ($ipFound) {
         // Rescan all the string, in case the mac address, in the string
         // returned by arp, comes before the ip address
      
         reset($valueSplitted);
         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)) {
               return $spLine;
            }
         }
      }
      $ipFound = false;
   }
}
return false;
}

Image
PRO Level 15
User avatar
Posts: 1346
Joined: Sun May 02, 2004 8:49 pm
Location: 127.0.0.1

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 0 guests