This topic is locked
[SOLVED]

MAC Address of the client PC

2/13/2022 3:43:12 PM
PHPRunner Tips and Tricks
G
ganesanmanju author

Is there any way to get client mac address ?

Thank you

DealerModulesDevClub member 2/13/2022

Googling around a little bit came up with this recent answer, hope it helps you.

Came from phpcoder.tech https://phpcoder.tech/php-get-client-mac-or-physical-and-ip-address/

Method-1:
<?php
echo GetMACAdd();

function GetMACAdd(){
ob_start();
system('getmac');
$Content = ob_get_contents();
ob_clean();
return substr($Content, strpos($Content,'\')-20, 17);
}
?>
Method-2:
<?php

ob_start(); // Turn on output buffering
system('ipconfig /all'); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer

$findme = "Physical";
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address

echo $mac;

?>
Code Highlights:
In the first method, we execute getmac the program and get the content.

In the second method, we execute system('ipconfig /all'); to display the output.

G
ganesanmanju author 2/13/2022

These all are giving the Mac address of server not client - please note.

Thanks

admin 2/14/2022

This is not possible. On the client computer you can only use Javascript and you do not have access to any physical details of the computer from Javascript.

S
Steve Seymour 2/14/2022

The best you can do is get the IP address...

<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>;

<script type="text/javascript">

document.write(returnCitySN["cip"]+','+returnCitySN["cname"])

</script>