Linux 中获取机器序列号的系统调用

发布于 2024-09-13 16:00:43 字数 130 浏览 8 评论 0原文

我知道这个可能性不大,但是有什么方法可以在 Linux 上获取序列号或唯一标识信息吗?

如果可以的话,如何将其编写成Java程序呢?

在上下文中,我需要构建一个锁定一台机器的许可证验证器。如果您还有其他建议,欢迎提出。

I know this is a long shot but is there any way of getting the serial number or a uniquely identifying piece of information on Linux?

If so, how can this be programmed into a Java program?

In context, I need to build a license validator that locks down to one machine. If you have any other suggestions they are welcome.

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

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

发布评论

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

评论(5

薄荷梦 2024-09-20 16:00:43

以下摘录自 Lennart Poettering 发表的有关 ID 的博客文章。它与唯一 ID 相关,不一定与安全相关的唯一 ID 相关:

  • /sys/class/dmi/id/product_uuid:主板产品 UUID,由
    板制造商和编码在
    BIOS DMI 信息。可能会用到
    识别主板并且仅
    主板。当用户使用时它会改变
    更换主板。还有,经常
    足够多的 BIOS 制造商写了假的
    连续剧进入其中。此外,它是
    x86 特定的。非特权访问
    用户被禁止。因此它是
    一般用途很少。

  • CPUID/EAX=3 CPU 序列号:CPU UUID,由 CPU 制造商设置
    并编码在CPU芯片上。可能是
    用于标识一个CPU并且仅标识一个CPU。
    当用户更换时它会改变
    中央处理器。此外,大多数现代 CPU 都没有
    不再实现此功能,并且
    较旧的计算机往往会禁用此功能
    默认选项,可通过
    BIOS 设置选项。此外,它是
    x86 特定的。因此这也是
    一般用途很少。

因此, /sys/class/dmi/id/product_uuid 似乎是验证守护进程的良好候选者,但这意味着您的验证代码需要以特权用户身份运行。完整的博客文章确实值得一读!

Here is an excerpt of a blog post by Lennart Poettering about IDs in general. It is about unique IDs, not necessarily about unique IDs in relation with security:

  • /sys/class/dmi/id/product_uuid: The main board product UUID, as set by the
    board manufacturer and encoded in the
    BIOS DMI information. It may be used
    to identify a mainboard and only the
    mainboard. It changes when the user
    replaces the main board. Also, often
    enough BIOS manufacturers write bogus
    serials into it. In addition, it is
    x86-specific. Access for unprivileged
    users is forbidden. Hence it is of
    little general use.

  • CPUID/EAX=3 CPU serial number: A CPU UUID, as set by the CPU manufacturer
    and encoded on the CPU chip. It may be
    used to identify a CPU and only a CPU.
    It changes when the user replaces the
    CPU. Also, most modern CPUs don't
    implement this feature anymore, and
    older computers tend to disable this
    option by default, controllable via a
    BIOS Setup option. In addition, it is
    x86-specific. Hence this too is of
    little general use.

So /sys/class/dmi/id/product_uuid seems like a good candidate for your validation daemon but means that your validation code needs to be run as a privileged user. The full blog post is really a valuable read!

揽月 2024-09-20 16:00:43

除非您实际上可以为用户计算机提供硬件加密狗,否则您无法设计出无法规避的复制保护设置。

如果您只是想告诉用户“嘿,您已经在网络上的另一台计算机上运行此许可证,请获取另一个许可证”,那么一个好方法是进行网络广播,以便他们可以找到彼此。最可靠的方法可能是使用 Zeroconf 和 jmdns 库。

如果您想确定该程序仅在具有给定序列号的一个位置运行,则使用通用 PC 执行此操作的唯一方法是让程序通过互联网调用中央母舰在运行时并在使用它的地方进行注册。然后,母舰返回一个包含需要运行的重要代码的片段。您很可能使用 Java WebStart 来实现这一点。

Unless you can actually get a hardware dongle to the users machine, you cannot devise a copy protection setting that cannot be circumvented.

If you just want to tell the user that "hey, you are already running this license on another machine on your network, get another license", then a good way is to do network broadcasts so they can find one another. The simplest way to do reliably is probably using Zeroconf with the jmdns library.

If you want to be certain that the program is only being run at one place with a given serial number, the only way to do so with generic PC's is to have the program call a central mothership over the internet while being run and register where it is being used. The mothership then returns a snippet containing important code needing it to be run. You could most likely implement this using Java WebStart.

意犹 2024-09-20 16:00:43

我使用 MAC 地址作为唯一 ID。

InetAddress address = InetAddress.getByName("192.168.1.1");
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();

I use the MAC-Adress as an unique id.

InetAddress address = InetAddress.getByName("192.168.1.1");
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();
如果没结果 2024-09-20 16:00:43

Mac地址可以更改。检查。此外,Mac 地址与接口(以太网/无线/HPNA 等)绑定。因此,聪明的用户可以轻松地对此进行调整。 stackoverflow 上也讨论了类似的问题。检查

Mac address can be changed. Check this. Also, Mac-Address is tied to an interface (Ethernet/Wireless/HPNA etc). So a smart user can easily tweak this up. There is a similar problem discussed on stackoverflow. Check this.

橙幽之幻 2024-09-20 16:00:43

MAC 地址不是一个好的选择,因为它在某些系统上可以更改。如果您想继续使用本机 Java,那么逻辑系统参数(例如机器 ID 和用户登录帐户)是您唯一的选择。在某些情况下,机器名称足够安全,因为一个网络上不可能有两台机器具有相同的名称。

The MAC address is not a good choice, as it can be changed on some systems. If you want to stay in native Java then logical system parameters such as the machine ID and user log-in account are your only options. For some cases machine name is adequately secure as there can't be two machines on the one network with the same name.

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