Getting remote User Mac address

断了今生、忘了曾经 提交于 2020-12-27 06:07:23

问题


I am working on a project using mongodb, express and nodejs to build an intranet based webapp. The goal of the project is to acquire a user mac address upon authentication and run a remote ssh. I am however finding it difficult to get the remote pc mac address. The clients and server are meant to be on the same local subnet. I tried using the node getmac module, but apparently it only gives host server's mac,

var macAddress = require('getmac');
require('getmac').getMac(function(err, macAddress){
if (err)  throw err
console.log(macAddress)
});

I also tried the macfromip module but with that you have to predefine the host IP to get the mac of the remote computer.

var macfromip = require('macfromip');
macfromip.getMac('192.168.1.100', function(err, data){
    if(err){
        console.log(err);
    }
    console.log(data);

});

Is there any other way i could get the user's mac address?


回答1:


Doesn't seem like you can get the MAC address from a IP.
The documentation of getMac doesn't have anything related to .getMac('192.168.1.100')

A way I would see this working is having a database with the IPs and their MAC address.
This would require something to save those each MAC address in the database. Probably a script running on startup on each computer.


Someone asked this question on security.stackexchange.com. As it is on the same network, if you use the command ping on the command line, the MAC address of that IP would be registered on ARP list.

ping your_ip_address

And with this you should be able to get the MAC Addresses:

arp -a

With that in mind, I found these 2 nodejs packages that might interest you: https://www.npmjs.com/package/ping and https://www.npmjs.com/package/node-arp




回答2:


I imagine you would have to do this client side and pass it back.

By the sounds of this SO answer you can't do it easily in in Javascript but the answer suggests:

  • Using Java (with a signed applet)
  • Using signed Javascript, which in FF (and Mozilla in general) gets higher privileges than normal JS (but it is fairly complicated to set up)


来源:https://stackoverflow.com/questions/49487915/getting-remote-user-mac-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!