Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Client Machine's Mac Address in a Web application

I have to get Mac Address of client's PC where my website is running. So how to get Mac Address of client's machine (not of the Server's Mac Address where website is hosted). I need script that is compatible with IE, Firefox, Safari and Chrome.

like image 468
nirav patel Avatar asked Mar 28 '12 08:03

nirav patel


People also ask

How do I find a client's MAC address?

To find the MAC ID / Address of a system, either: Locate the MAC ID label on the back plastics of the system. On integrated thin clients, the MAC ID label is located on the back, below the power input jack. On thin client computers, the MAC ID label is located on the back of the system, below the certification label.

Can a website capture MAC address?

To answer the original question, a web site can read your MAC address, but they need to have special scripts on their servers and force your browser to download them.

Can I get MAC address from request?

The MAC address isn't in the client request headers, so the only thing you've got in the clients IP address to use. You can't get the MAC address of the client unless the server is on the same network segment as the client.

Can you get MAC address using JavaScript?

No you cannot get the MAC address in JavaScript, mainly because the MAC address uniquely identifies the running computer so it would be a security vulnerability.


3 Answers

The only way to achieve this is by using an applet or plugin which could for example be programmed in java (although java itself might not allow it according to Getting MAC address on a web page using a Java applet ), as javascript will naturally not disclose this kind of information. Lastly you could also find this information from the server side if it's on an internal network as is often done with semi-private wifi network landing pages.

Based on the comments below: As it's an internal network you can retrieve the mac address as follows on the asp.net side. You execute the following command arp -a which will return you a list of all ip addresses with associated mac addresses. Next using something along the lines of

Request.Servervariables("REMOTE_ADDR")

you should be able to find the users ip address which you can next match with the data you retrieved from the arp command and voila, you have your mac address for the current user.

like image 154
David Mulder Avatar answered Oct 18 '22 01:10

David Mulder


I have scenario where some user are allowed from some fixed PC (for which MAC address entered by admin will match with system from where user try to logged in) , he/she will not able to logged in from other than those PC

To achieve the above the right way, you should be relying on Client certificates to perform the authentication. If a valid client certificate is not presented then the request will be denied.

You can find more information on Securing a website using client certificates @ http://support.microsoft.com/kb/315588

If the users are in internal network, preferred way to authenticate them is using the Integrated windows authentication as described http://support.microsoft.com/kb/323176 and authorization will be based on a Access control list

like image 40
Ramesh Avatar answered Oct 18 '22 02:10

Ramesh


Sounds like this is an internal network.

Another method is that by using mac address the dhcp server can assign particular ip ranges. you can then check for that ip range in your server code. There is not a way to get mac address in javascript, but you can get the ip easily. Also perhaps your dhcp server can publish mac address ip address tables for your web server to use via an api or something - not sure on that but may be worth looking into.

like image 2
Symeon Breen Avatar answered Oct 18 '22 01:10

Symeon Breen