Is there really any way to uniquely identify any computer at all
Asked Answered
B

5

28

I know there are a number of similar questions in stackoverflow such as the followings:

... and dozens more and I have studied them all.

The problem is that some of the accepted answers have suggested MAC address as an unique identifier which is entirely incorrect. Some other answers have suggested to use a combination of various components which seems more logical. However, in case of using a combination it should be considered which component is naturally unlikely to be changed frequently. A few days ago we developed a key generator for a software licensing issue where we used the combination of CPUID and MAC to identify a windows pc uniquely and till practical testing we thought our approach was good enough. Ironically when we went testing it we found three computers returning the same id with our key generator!

So, is there really any way to uniquely identify any computer at all? Right now we just need to make our key generator to work on windows pc. Some way (if possible at all) using c# would be great as our system is developed on .net.

Update:

Sorry for creating some confusions and an apparently false alarm. We found out some incorrectness in our method of retrieving HW info. Primarily I thought of deleting this question as now my own confusion has gone and I do believe that a combination of two or more components is good enough to identify a computer. However, then I decided to keep it because I think I should clarify what was causing the problem as the same thing might hurt some other guy in future.

This is what we were doing (excluding other codes):

We were using a getManagementInfo function to retrieve MAC and Processor ID

private String getManagementInfo(String StrKey_String, String strIndex)
    {
        String strHwInfo = null;
        try
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + StrKey_String);
            foreach (ManagementObject share in searcher.Get())
            {
                strHwInfo += share[strIndex];
            }
        }
        catch (Exception ex)
        {
            // show some error message
        }
        return strHwInfo;
    } 

Then where needed we used that function to retrieve MAC Address

string strMAC = getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress");

and to retrieve ProcessorID

string strProcessorId = getManagementInfo("Win32_Processor", "ProcessorId");

At this point, strMAC would contain more than one MAC address if there are more than one. To take only one we just took the first 17 characters (12 MAC digits and 5 colons in between).

strMAC = strMAC.Length > 17 ? strMAC.Remove(17) : strMAC;

This is where we made the mistake. Because getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress") was returning a number of extra MAC addresses that were really in use. For example, when we searched for MAC addresses in the command prompt by getmac command then it showed one or two MAC addresses for each pc which were all different. But getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress") returned four to five MAC addresses some of which were identical for all computers. As we just took the first MAC address that our function returned instead of checking anything else, the identical MAC addresses were taken in strMAC incidently.

The following code by Sowkot Osman does the trick by returning only the first active/ enabled MAC address:

private static string macId()
    {
        return identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");
    }

private static string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
    {
        string result = "";
        System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);
        System.Management.ManagementObjectCollection moc = mc.GetInstances();
        foreach (System.Management.ManagementObject mo in moc)
        {
            if (mo[wmiMustBeTrue].ToString() == "True")
            {
                //Only get the first one
                if (result == "")
                {
                    try
                    {
                        result = mo[wmiProperty].ToString();
                        break;
                    }
                    catch
                    {
                    }
                }
            }
        }
        return result;
    }
    //Return a hardware identifier
    private static string identifier(string wmiClass, string wmiProperty)
    {
        string result = "";
        System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);
        System.Management.ManagementObjectCollection moc = mc.GetInstances();
        foreach (System.Management.ManagementObject mo in moc)
        {
            //Only get the first one
            if (result == "")
            {
                try
                {
                    result = mo[wmiProperty].ToString();
                    break;
                }
                catch
                {
                }
            }
        }
        return result;
    }

However, I was absolutely right about the identical Processor ID issue. All three returned the same Processor ID when we put wmic cpu get ProcessorId command in their command prompts.

Now we have decided to use Motherboard serial number instead of Processor ID to make a combination with MAC address. I think our purpose will be served with this way and if it doesn't in some cases then we should let it go in those few cases.

Bunde answered 28/2, 2012 at 12:52 Comment(14)
The simple answer has to be no. Since a PC is made of many interchangeable parts. Over time the only thing that may stay the same is the case. So the first thing you need to specify is which parts of the PC (in terms of hardware) you consider to be 'the PC'. Whatever you choose is going to be a compromise of some sort hence the ambiguity or in-correctness in your view of the previous answers.Urano
I believe the TPM could help, but it is usually available on business class laptops, and disabled by default. +1 for your study of the subject!Avaricious
You can clone virtual machines easily, just by copying the virtual hard disk file. Now you can have to virtual machines with identical hardware and software.Tourcoing
If you're using CPUID and MAC Address to identify the machine and three machines are returning the same ID, then there's a bug in your code. MAC addresses are globally unique, assigned at the factory.Tetrachord
MAC addresses are almost always a good choice. They have three important properties: they're normally unique, they don't change routinely, and they can be manipulated when necessary. The latter property is important. Good quality software must give the sysadmin a way to override the DRM when necessary!Holds
MAC addresses can be changed/ spoofed and so it can be unwise to rely on this as a single method of authentication. That's why we decided to use a combination of both MAC and CPUID influenced by the suggestions given by @Paul Alexander and others from the previously posted similar questions. Getting same id even after that is very weird and bizarre. We used another software to re-check the issue and that also returned same MAC and Processor ID for two computers out of three and we haven't tested on the third one yet.Bunde
If you're going to insist on using the motherboard serial number please make sure your code can cope if retrieving the serial number doesn't work. It probably isn't possible for a virtual machine, for example, and might not be possible even on real hardware in some cases. (I still think it's a bad decision, because it leaves the user completely stuck if the motherboard in question dies, which is lousy customer relations.)Holds
Regarding the processor ID: lots of hardware doesn't allow this to be retrieved (or requires the admin to change the BIOS settings before it can be retrieved) for privacy reasons. Perhaps the ID you're seeing is some kind of default value used when the real ID isn't available?Holds
@HarryJohnston, Thanks for sharing your thoughtful opinion. I think finally I might go with what Sal has suggested. I have a couple of days more in my hand to make a final decision. Till then I am open for any better suggestions.Bunde
MAC Addresses can be configured in Windows - but your code can detect that as well. If you're allowing spoofed MAC addresses in your ID then that is a bug in the software. Getting this right on all possible machines is very difficult. If you want a hardware based license get a tool from a copy protection vendor and let them handle it.Tetrachord
@PaulAlexander Can you please provide me some help/ links about how to detect spoofed MAC addresses and retrieve the original MAC if spoofed found? I have found out some tools that can do that but I need to do that myself with codes. Thanks.Bunde
Spoofed MAC IDs are effective only in LAN. If functions like getManagementInfo("Win32_NetworkAdapterConfiguration", "MacAddress") are used inside the system, it actually retrieves the original MAC ID from the hardware instead of spoofed MAC ID. So, don't worry about MAC address spoofing.Stylographic
@HUNKY_Monkey, it returns the spoofed MAC Address.Bunde
@PaulAlexander, you said, "MAC Addresses can be configured in Windows - but your code can detect that as well. If you're allowing spoofed MAC addresses in your ID then that is a bug in the software." If you said it right then please answer [this] (#9546728) questionBunde
S
5

The fact in getting a globally unique ID is, only MAC address is the ID that will not change if you set up your system all over. IF you are generating a key for a specific product, the best way to do it is assigning unique IDs for products and combining the product ID with MAC address. Hope it helps.

Stylographic answered 29/2, 2012 at 7:2 Comment(5)
combining the product ID with MAC address seems to be a really good idea. +1Bunde
Please Don't panic about the name change. I just merged two of my accounts. Still the same person as before. :) Sorry for this comment considering it inconvenient to this post.Stylographic
Not a problem at all. BTW can you answer this: #9546728Bunde
MAC address can be changed by users.Kenton
Also, replacing a network card definitely changes the MAC address: This is a really great way to uniquely identify a network card, not a computer.Stabilizer
A
11

How about adding motherboard serial number as well e.g.:

using System.management;


//Code for retrieving motherboard's serial number
ManagementObjectSearcher MOS = new ManagementObjectSearcher("Select * From Win32_BaseBoard");
foreach (ManagementObject getserial in MOS.Get())
{
textBox1.Text = getserial["SerialNumber"].ToString();
}

//Code for retrieving Processor's Identity
MOS = new ManagementObjectSearcher("Select * From Win32_processor");
foreach (ManagementObject getPID in MOS.Get())
{
textBox2.Text = getPID["ProcessorID"].ToString();
}

//Code for retrieving Network Adapter Configuration
MOS = new ManagementObjectSearcher("Select * From Win32_NetworkAdapterConfiguration");
foreach (ManagementObject mac in MOS.Get())
{
textBox3.Text = mac["MACAddress"].ToString();
}
Anthology answered 28/2, 2012 at 12:59 Comment(4)
helpful tips, thanks. I'll wait for more answers before accepting though. +1 anyway :)Bunde
Does this require admin privilege?Holds
for anybody who get "Base Board Serial Number" see https://mcmap.net/q/504721/-wmi-win32_baseboard-serialnumber/184572Goldarned
User needs WMI access proviledges, which can be added by executing commands with Administrator priviledges (check codeproject.com/Articles/15848/WMI-Namespace-Security) But with some computers SMBIOS UUID is changing after reboot, and with other it contains only zeros or only FF... So combining multiple IDs from different sources keeps being the only way to get a reliable system...Clipboard
S
5

The fact in getting a globally unique ID is, only MAC address is the ID that will not change if you set up your system all over. IF you are generating a key for a specific product, the best way to do it is assigning unique IDs for products and combining the product ID with MAC address. Hope it helps.

Stylographic answered 29/2, 2012 at 7:2 Comment(5)
combining the product ID with MAC address seems to be a really good idea. +1Bunde
Please Don't panic about the name change. I just merged two of my accounts. Still the same person as before. :) Sorry for this comment considering it inconvenient to this post.Stylographic
Not a problem at all. BTW can you answer this: #9546728Bunde
MAC address can be changed by users.Kenton
Also, replacing a network card definitely changes the MAC address: This is a really great way to uniquely identify a network card, not a computer.Stabilizer
B
2

I Completely agree with just the above comment.

For Software licensening, you can use:

Computer MAC Address (Take all if multiple NIC Card) + Your software Product Code

Most of the renowned telecom vendor is using this technique.

Benoni answered 29/2, 2012 at 11:41 Comment(0)
L
1

However, I was absolutely right about the identical Processor ID issue. All three returned the same Processor ID when we put wmic cpu get ProcessorId command in their command prompts.

Processor ID will be same if all the systems are running as virtual machines on the same hypervisor.

MAC ID seems fine. Only thing is users must be provided the option to reset the application, in case the MAC changes.

Lounge answered 12/9, 2013 at 10:33 Comment(0)
C
1

It looks like custom kitchen is the way for that.

SMBIOS UUID (motherboard serial) is not robust, but works fine in 99% cases. However some brands will set the same UUID for multiple computers (same production batch maybe). Getting it requires WMI access for the user (if he's not administrator), you can solve that by starting an external process asking administrator priviledges (check codeproject.com/Articles/15848/WMI-Namespace-Security)

Windows Product ID might be good, but I read it could be identical in some circumstances (https://www.nextofwindows.com/the-best-way-to-uniquely-identify-a-windows-machine) Could someone clarify if the same Product ID (not product key) might be present on multiple computers ?

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid seems interesting. It's generated when installing Windows and if changed, it requires to reactivate Windows.

Mac Addresses are interresting but you can only take the first one or your unique ID will change when the interface is disabled, or when another network interface is added and appears first etc.

Hard Drive serial number is nice but when installing a ghost, it might also override the serial number from the original drive... And the HD serial is very easy to change.

The best might be to generate an ID with a combination of those machine identifiers and decide if the machine is the same by comparing those identifiers (ie if at least one Mac address + either SMBIOS UUID or Product ID is ok, accept)

Clipboard answered 31/12, 2019 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.