且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Web 应用程序中获取客户端计算机的 Mac 地址

更新时间:2022-05-08 22:25:14

实现这一目标的唯一方法是使用小程序或插件,例如可以用 Java 编程(尽管根据 使用 Java 小程序获取网页上的 MAC 地址 ),因为 javascript 自然不会泄露此类信息.最后,如果它位于内部网络上,您也可以从服务器端找到此信息,这通常通过半专用 wifi 网络登录页面完成.

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.

基于以下评论:由于它是内部网络,您可以在asp.net端按如下方式检索mac地址.您执行以下命令 arp -a 它将返回所有 ip 地址的列表以及关联的 mac 地址.接下来使用类似

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")

您应该能够找到用户的 ip 地址,接下来您可以将其与从 arp 命令检索到的数据进行匹配,瞧,您拥有当前用户的 mac 地址.

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.