Getting the MAC-Address of a client with a browser
Asked Answered
K

2

12

I have the following problem: I have a webserver. This webserver is behind a router. The problem is, I need the MAC-Address of a client that opens a website on the server for further purposes. I tried already to get the MAC-Address via an ActiveX-Object, but the client needs WMI installed. Here is the actual code:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
        <title></title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
        <script id="clientEventHandlersJS" language="javascript">

function Button1_onclick() {
  var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  var service = locator.ConnectServer(".");
  var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
  var e = new Enumerator (properties);
  document.write("<table border=1>");
  dispHeading();
  for (;!e.atEnd();e.moveNext ())
  {
        var p = e.item ();
        document.write("<tr>");
        document.write("<td>" + p.Caption + "</td>");
        document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
        document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
        document.write("<td>" + p.IPXAddress + "</td>");
        document.write("<td>" + p.IPXEnabled + "</td>");
        document.write("<td>" + p.IPXNetworkNumber + "</td>");
        document.write("<td>" + p.MACAddress + "</td>");
        document.write("<td>" + p.WINSPrimaryServer + "</td>");
        document.write("<td>" + p.WINSSecondaryServer + "</td>");
        document.write("</tr>");
  }
  document.write("</table>");
}

function dispHeading()
{
    document.write("<thead>");
    document.write("<td>Caption</td>");
    document.write("<td>IPFilterSecurityEnabled</td>");
    document.write("<td>IPPortSecurityEnabled</td>");
    document.write("<td>IPXAddress</td>");
    document.write("<td>IPXEnabled</td>");
    document.write("<td>IPXNetworkNumber</td>");
    document.write("<td>MACAddress</td>");
    document.write("<td>WINSPrimaryServer</td>");
    document.write("<td>WINSSecondaryServer</td>");
    document.write("</thead>");
}

        </script>
  </head>
  <body>

        <INPUT id="Button1" type="button" value="Button" name="Button1" language="javascript" onclick="return Button1_onclick()">
  </body>

When you click on the button, it should return a table with the network configuration, but that doesn't work for me. I'd like to know, if there is another solution for getting the MAC-Address of a client via browser. I also don't want to limit the usage on Internet Explorer. Thanks in advance for your help.

Regards, Chris

Kempf answered 23/4, 2012 at 8:50 Comment(6)
Why do you need to know the MAC address?Predigestion
Because I want to send a request to a managed switch via SNMP for getting the connected port of the client. My company is making a facility management software and via the MAC-Address, we can find out in which room the client is. After we found out in which room the client is, we display a website to control the actual room. You can send commands to your interior blinds, set the room temperature or open the window with the "room management website".Kempf
did you find any solution for this? I am trying to do the samePinite
did you find any solution? i am trying to do the same.Claire
No, actually we found no way to achieve the MAC address at all.Kempf
Any solution for this? I'm also trying this same now if any one having solution for this case please share.Lorrielorrimer
P
8

It seems that you can do this using a Java Applet, see postst at https://forums.oracle.com/forums/thread.jspa?threadID=1144276 and http://techdetails.agwego.com/2008/02/11/37/.

Not sure if you need the user to agree a security warning for this or not, I have not tried it.

There is probably no better way, since ActiveX will only work on Windows (and IE only), and there is no such API to get MAC address in any standard HTML or JavaScript. I don't know if Flash can be useful for this, but I doubt that.

However, your reason to get user's MAC address may seem valid, but I still think it's not a good idea to deduce any information it, because it can be spoofed/changed and may not show properly in certain situations. You would do better, if you could come up with a better solution for your problem (not involving grabbing MAC addresses).

Predigestion answered 23/4, 2012 at 9:8 Comment(4)
The clients don't have permissions to change any system settings and we have no other solution for resolving the connected port to a room instead of the MAC-Address... Btw, I'm trying to use the Java-Applet, but it doesn't really work. It only shows an empty MessageBox... :/Kempf
Is your server on the same subnet? You could get MAC address remotely, then. If not, what about running a proxy server on each subnet, that would relay this information?Predigestion
The problem is, the network is not managed by us and we have to customize our software to make it working. The server is behind a router and not in the same subnet. We have no possibility to set up proxy servers due to network security settings, given by our customer.Kempf
I tried the Java-Applet from the link, but it doesn't work with the newest Java-Version anymore :(Kempf
J
4

In my previous project. we used websocket in browser javascript to communicate with a native code, a C# dll, running on the same machine. The native code can retrieve any system info, MAC address and other system info like memeory, disk space, etc. Node.js can be used to replace C# as well just to break the limit of windows machin and into MAC machine. The entire app ( chrome browser + native code ) was downloaded to client using install shield.

Jural answered 17/6, 2017 at 13:20 Comment(3)
This sounds like a question, not an answer. Post a question.Fibrovascular
This does not provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractionsBoulogne
Looks like an answer to me. the author's saying that he solved this problem with native+browser, which is a solution, and thus an answer. The author notes they are looking into whether it can be done just with the browser, but that's clarification on the scope of the answer not a new question.Larder

© 2022 - 2024 — McMap. All rights reserved.