Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I uniquely identify a machine in C?

I want to uniquely identify a machine in C.

The following are sources which have serial numbers, but they aren't guaranteed to be unique, or present (like a removable HDD or network card).

  • CPU: I'm using the cpuid instruction, however, serial number is not implemented for any processor except Pentium 3, i.e. not relevant. I can use the processor signature, but this won't be unique for every processor.
  • HDD: ?
  • BIOS: ?
  • motherboard: ?
  • MAC address: via system function calls.

For all the question marks, how would I get the serial numbers in C? If you answer with a system dependent solution, please provide both Windows/*nix. Also, for Windows, please no WMI.

Thanks!

like image 515
chacham15 Avatar asked Sep 16 '11 06:09

chacham15


People also ask

How do you identify a uniquely machine?

Use UUID as the Identifier When You Can That UUID is the best way to ID a machine, it exists in Windows, Mac and many other platforms. It is 32 characters in length, a universally unique identifier.

How do I identify my computer?

Click on the Start button. In the search box, type Computer. Right click on This PC within the search results and select Properties. Under Computer name, domain, and workgroup settings you will find the computer name listed.

How do I identify a unique laptop?

On a desktop computer, this sticker is usually on the side or back of the computer. Laptop computers often have this sticker on the bottom of the computer. If you still cannot find the product number and your computer came with Microsoft Windows, contact your computer manufacturer to purchase a new number.

Do computers have a unique ID?

A GUID (globally unique identifier) is a 128-bit text string that represents an identification (ID). Organizations generate GUIDs when a unique reference number is needed to identify information on a computer or network. A GUID can be used to ID hardware, software, accounts, documents and other items.


1 Answers

Generally speaking, you need to identify a combination of components and understand that components can and will change over time. You need tolerance algorithms to make an informed guess about when a change represents an update to a machine you previously identified, or a new machine you have not seen before.

A simple approach would be to enumerate all of the components you listed when you need to determine which machine you're dealing with and compare to previous snapshots of machines you have previously seen. If anything with a serial number matches, you can pretty safely assume you're dealing with the same machine (though of course it's possible that someone transferred a hard drive to a new machine... but then, this is the simple approach. Commercial grade heuristics are much more complicated.).

Use of this approach specifically for software activation is covered by a patent that is actively enforced, so be careful about what you're doing. If you do want to do this to protect your software, it may be better to use a commercial solution. Some are quite affordable. Google "software activation" for options.

Here are some references for obtaining the specific system information (not all are specific C cookbooks, but C can be used in each case).

HDD Windows http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx

HDD Linux http://www.webmasterworld.com/forum40/957.htm

BIOS Windows http://msdn.microsoft.com/en-us/library/aa394077(v=vs.85).aspx

BIOS Linux http://www.dufault.info/blog/a-better-way-to-find-your-bios-version-in-linux/

MAC Address Windows C++: Get MAC address of network adapters on Vista?

MAC Address Linux http://www.linuxquestions.org/questions/programming-9/linux-determining-mac-address-from-c-38217/

like image 87
Eric J. Avatar answered Oct 05 '22 16:10

Eric J.