7

Possible Duplicate:
WIN32_Processor::Is ProcessorId Unique for all computers

I'm creating an application with a trial feature. To detect if a certain user already used a trial the application connects to my server with their machineHash.

The machineHash function look like this:

string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
    if (cpuInfo == "")
    {
        //Get only the first CPU's ID
        cpuInfo = mo.Properties["processorID"].Value.ToString();
        break;
    }
}
return cpuInfo;

However, it does report my processor ID as BFEBFBFF000206A7 (on two different Intel machines, i5 and a Celeron). Googling BFEBFBFF000206A7 has hits too, so it's not unique.

Could anyone tell me why this is not unique? I don't want to use the VolumeSerial of let's say the C:\ drive as that can be easily changed with a simple command.

Community
  • 1
  • 1
Devator
  • 3,686
  • 4
  • 33
  • 52
  • Consider using/adding a MAC address off the user machine to your scheme, however you will need more to make this work properly. – DWright Dec 24 '12 at 17:08
  • 2
    MAC addresses can be faked. [Quite easily too](http://devices.natetrue.com/macshift/). I wouldn't rely on that. – Jeff Hubbard Dec 24 '12 at 17:09
  • @DWright No, since you would have other issues (as with laptops, they mostly have both wired and wireless and other (VPN) adapters). I just need something simple. – Devator Dec 24 '12 at 17:09
  • 1
    Maybe CPUID is even flawed at its root : http://en.wikipedia.org/wiki/CPUID EAX=3 "this feature is no longer implemented " – rene Dec 24 '12 at 17:11
  • Yeah, the above caveats are why I said more would be needed. I only mentioned MAC address, because in a naive implementation this can be relied upon to be unique, but the issue of spoofing of Mac address would still be there. In any case you'd have to do some work to make sure you are getting the address of a real adapter (not virtual, not vpn, not loopback). I think you can see from the various comment, that you may need to find a more robust approach entirely. – DWright Dec 24 '12 at 17:14

1 Answers1

8

Instead of using the processor ID, combine multiple ID's of a system into 1 string to compare each time the program sends check.

Use something like this:

using System.Management;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"select * from " + whatever_id);

All the values you can replace whatever_id with can be found here: http://www.codeproject.com/Articles/17973/How-To-Get-Hardware-Information-CPU-ID-MainBoard-I

I would find a few you want to use, some of which can be unique, but even if you dont use a unique field, you can make combinations that will, for most intents and purposes, be unique.

Titus P
  • 959
  • 1
  • 7
  • 16