Skip to content

Instantly share code, notes, and snippets.

@kheniparth
Created September 14, 2014 17:33
Show Gist options
  • Save kheniparth/d3f76ff4f6d2016117f1 to your computer and use it in GitHub Desktop.
Save kheniparth/d3f76ff4f6d2016117f1 to your computer and use it in GitHub Desktop.
How to find MAC address of your visitor using PHP
<?php
ob_start();
system('ipconfig /all');
$mycom=ob_get_contents();
ob_clean();
$findme = "Physical";
$pmac = strpos($mycom, $findme);
$mac=substr($mycom,($pmac+36),17);
echo $mac;
?>
@Kangkhita
Copy link

It works on local server not on online server. Then what to do??
please help...

Copy link

ghost commented Aug 24, 2016

It only works as long as the data packet hasn't been passed on by the router, so it only works when your visitor is on the same network. Once the data is sent out, the MAC address in the data packets changes to that of the passing node and that continuously repeats as the packets hop through the internet. There is no way to recover the MAC address of the original host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment