views:

64

answers:

5

I know this is a long shot but is there any way of getting the serial number or uniquely identifiable piece of information in 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.

Thanks in advance

A: 

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();
stacker
Prior to 1.6, getting MAC address was pretty tricky, IIRC. I think native code or parsing command line output was required.
Sam Brightman
A: 

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.

Tushar Tarkas
A: 

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.

Thorbjørn Ravn Andersen
I forgot to mention in my question that the unit cannot call home over the internet
Ross Alexander
Then I would go for a commercial solution if you need this to be fool proof.
Thorbjørn Ravn Andersen
+1  A: 

Here is an excerpt of a blog post by Lennart Poeterring about IDs in general. It is about unique ID, not necessarily about unique ID 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 alidation daemon like a good candidate, but needs your validation code to be run as a privileged user. The full blog post is really a valuable read !

shodanex
A: 

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.

Dominic