0

As you can see in the title what I want to do, now I know that you can not trace a client's MAC address if the client is not on the same network. However I've read here in the answer that if a client volunteer, you can get that info. But I don't know how.

Scenario: A system with confidential data is in need to implement a login mechanism that rejects a login request if requested outside from the office premises and from other devices. If I implement an IP tracing, a genuine user could get locked out, if for some reason IP gets changed.

Please advise how can I trace MAC address of a client with their permission (if it's possible). If I can not trace the MAC addresses, what could be the better approach to the above mentioned scenario?

Saud
  • 859
  • 1
  • 9
  • 23
  • What if an authorised user uses a different computer? Relying on a MAC address is a bit fragile and perhaps you should look for some other method for securing the login. – Nigel Ren Jul 10 '20 at 07:37
  • @NigelRen well if an authorized user gets rejected if they try to use another device it could be better. But I would rather stick to my current scenario and seek for advice for a better approach to the mentioned scenario. It would be highly appreciable if you have another approach to it. thanks. – Saud Jul 10 '20 at 08:00
  • Two factor authentication may work - https://stackoverflow.com/questions/5785781/two-factor-authentication-system has some discussion about that with varying solutions. – Nigel Ren Jul 10 '20 at 08:11
  • @NigelRen Got it. Thanks! – Saud Jul 10 '20 at 09:50

2 Answers2

2

Basically, you can't.

MAC addresses are never transfered beyond the router connecting a lan segment to the internet..

You cannot get the MAC address of a client from the server - you can only get it from the client, which means you would need Javascript code - and you can't access the MAC address in javascript code either, which also excludes JQuery. Any attempt to get the MAC in PHP will return the server MAC Address, because that is the computer on which the PHP code executes.

The MAC address is not broadcast beyond the LAN the device is connected to - it never leaves the router and passes to the server.

STA
  • 30,729
  • 8
  • 45
  • 59
  • Yes I know that I can't get a client's MAC address on the different network. But that's new to me that there is simply no way that I can get it. I would not rely on JS because it's a huge security issue. What could be the better approach for this particular scenario, any help would be appreciated. – Saud Jul 10 '20 at 08:03
  • @Suad, acctually you cant do that. Because no browser send this type of info to server side, when browsing. – STA Jul 10 '20 at 08:06
  • No I mean, the scenario I mentioned. For the reason I'm trying to get MAC addresses. Is there any good approach to it rather than tracing MAC addresses? – Saud Jul 10 '20 at 08:08
-1

The ‘exec()’ is a function that is used to run an external program in PHP. It returns the last line from the result of the command. To get the MAC address, pass the parameter ‘getmac’ which returns the MAC address of the client. ‘getmac’ is a CMD command to get the MAC address.

To get the MAC address, we use exec() function.

$macAddr = exec('getmac');
  • It will return me the MAC address of the machine that execute it, which is the server on which the php script will run and `exec()` the command. Just like @sta defined, it will bring me the MAC address of the server not the client. – Saud Jul 03 '21 at 09:08