如何在不使用activex的情况下获取客户端的mac地址

发布于 2024-11-18 00:16:08 字数 130 浏览 6 评论 0原文

我的主要目的是给每台使用网站的机器一个唯一的id,一种方法是找到客户端的mac地址,但不使用activex,也不能使用cookie分配ID,因为cookie可以被删除并且不能也使用最后一个修改日期方法,所以关于如何分配唯一 ID 的任何想法,谢谢

My main purpose is to give every machine using the website a unique id, one way would be to find the mac address of the client, but not using activex, and also cant assign ID using cookie because cookies can be deleted and not also using last modified date method, so any ideas on how I could assign a unique ID, thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不美如何 2024-11-25 00:16:08

也许可以使用java小程序来做到这一点,但是HTML和Web浏览器策略经过精心设计,可以防止您做这样的事情,因为它会被认为是重大安全风险。如果没有 ActiveX 控件(如果被发现,可能会因为向 javascript 提供此类个人信息而被禁止,除非您确实仔细计划了安全性)或至少需要一个 Java 小程序,那么 Mac 地址当然是不可能获取的。用户授予其提升的权限。

大多数公司只是分配一个唯一的 ID 并将其存储在浏览器的 cookie 中。有诸如 FireBreath 之类的技术可以轻松创建浏览器插件(activex 控件和 npapi 插件),但同样 - - 你所说的可能是一个非常非常糟糕的主意,所以要小心行事。

You might be able to do this using a java applet, but HTML and web browser policies are very carefully designed to prevent you from doing something like this, as it would be considered a major security risk. A Mac address is certainly not possible to grab without either an activex control (which if discovered would probably get banned for providing such personal information to javascript, unless you had really carefully planned security) or at the very least a java applet that would require the user to grant it elevated privileges.

Most companies just assign a unique id and store it in a cookie in the browser. There are technologies such as FireBreath that make it easy to create browser plugins (activex control and npapi plugin), but again -- what you're talking about has the potential to be a very, very bad idea, so tread with care.

风向决定发型 2024-11-25 00:16:08

我知道回复这篇文章已经太晚了..但是为了分享我的经验,我发布了我的答案。(我也遇到了同样的问题)

我使用了小程序并将其部署在客户端的计算机上。

import java.applet.Applet;
import java.applet.Applet;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;


public class app extends Applet{

public String macAddr="";

public void init()
 {
    try
        {
            System.out.println("Start");
            InetAddress ip = InetAddress.getLocalHost();
            System.out.println((new StringBuilder("Current IP address:"+ip.toString())));
            NetworkInterface network = NetworkInterface.getByInetAddress(ip);
            byte mac[] = network.getHardwareAddress();
            System.out.println("mac : "+mac.toString());
            System.out.print("Current MAC address : ");
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < mac.length; i++)
                sb.append(String.format("%02X%s", new Object[] {
                        Byte.valueOf(mac[i]), i >= mac.length - 1 ? "" : "-"
                }));

            System.out.println(sb.toString());
            macAddr=String.valueOf(sb);
            System.out.println("okay good");

        }
     catch(SocketException e)

        {
            macAddr=e.toString();
            e.printStackTrace();
            System.out.println("not good");
        }
        catch (Exception e) {
            macAddr=e.toString();
            e.printStackTrace();
            System.out.println("bad good");
        }    
     }
       }

我在制作这个小程序后遇到的问题是[当我在本地机器上运行它时它工作正常(作为小程序运行)],但它不能在服务器上运行``
为此,您必须签署您的 jar

Keytool -genkey -alias signFiles -keystore compstore -keypass KEYPASS -dname "cn=XYZ" -storepass KEY -validity 125000
jarsigner -keystore compstore -storepass PASS -keypass KEYPASS appletname.jar signFiles

之后它工作但不顺利..每次我运行它时。浏览器都会请求许可。
这不好。
希望我的经验有帮助

I know its too late to reply for this post..but to share my experience i am posting my answer.(I too faced the same problem)

I used the applet and deployed it on client's machine.

import java.applet.Applet;
import java.applet.Applet;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;


public class app extends Applet{

public String macAddr="";

public void init()
 {
    try
        {
            System.out.println("Start");
            InetAddress ip = InetAddress.getLocalHost();
            System.out.println((new StringBuilder("Current IP address:"+ip.toString())));
            NetworkInterface network = NetworkInterface.getByInetAddress(ip);
            byte mac[] = network.getHardwareAddress();
            System.out.println("mac : "+mac.toString());
            System.out.print("Current MAC address : ");
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < mac.length; i++)
                sb.append(String.format("%02X%s", new Object[] {
                        Byte.valueOf(mac[i]), i >= mac.length - 1 ? "" : "-"
                }));

            System.out.println(sb.toString());
            macAddr=String.valueOf(sb);
            System.out.println("okay good");

        }
     catch(SocketException e)

        {
            macAddr=e.toString();
            e.printStackTrace();
            System.out.println("not good");
        }
        catch (Exception e) {
            macAddr=e.toString();
            e.printStackTrace();
            System.out.println("bad good");
        }    
     }
       }

The problem i faced after making this applet is[That it worked fine when i run it on Machine locally (RUN AS APPLET)], buT IT DOESNT WORK ON SERVER``
for that you have to sign your jar

Keytool -genkey -alias signFiles -keystore compstore -keypass KEYPASS -dname "cn=XYZ" -storepass KEY -validity 125000
jarsigner -keystore compstore -storepass PASS -keypass KEYPASS appletname.jar signFiles

After that it worked but not smoothly..as everytime i run it.Browser asks for permission.
which is not good.
I hope my experience helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文