Page 1 of 1

Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 12:25 pm
by jitspoe
In Windows, I can do this through WMI, but I really have no clue how to do it on Linux. I'm looking to be able to obtain serial numbers on things like hard drives and motherboards.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 2:00 pm
by paulbarker
Open the box?

All things I've seen with serial numbers have them printed on the device. I know this is dodging the question, but it depends if you just want the serial numbers or need to be able to read them from software. If it's the latter I'm sorry I can't help there.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 3:08 pm
by jitspoe
In short, I'm trying to generate a unique computer ID -- preferably something that can't be changed -- so it needs to be done in software.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 4:17 pm
by paulbarker
Start with the MAC address of the first network card if available. Take a look at the output of 'lspci' and 'lsusb' to see if you get anythin useful. Maybe add in a random number and hash the lot together.

By saying that you want an ID that cannot be changed, what exactly do you mean? Do you mean can't be spoofed (one comp can pretend to be another), is different for every comp, or survives across small hardware changes?

The usage for the ID will determine the characteristics that the ID should have and where the source data (used to create the ID) should come from.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 10:57 pm
by jitspoe
This is actually for a game I'm developing. Somebody suggested I ask in here. I want to be able to have hardware-level bans like punkbuster uses, because there have been instances where cheaters use dynamic ip's or proxies to evade bans.

I tried the commands you suggested, but they just gave some general information/descriptions. I didn't see any serial numbers. Most PCI and USB devices don't have serial numbers anyway. Typically the things that do are hard drives, motherboards and bios's.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 11:20 pm
by Candy
You can hash the bios: read from /dev/mem between 0xF0000 and 0xFFFFF and calculate a hash. It should probably work between 0xFFFF0000 and 0xFFFFFFFF as well. The first is the shadow (so it might be overwritten, but I doubt anybody would overwrite their bios shadow for using your game). This includes some hardware info so you're locked onto that specific configuration. The 0xFFFF0000 location probably doesn't contain that information, but I'm not sure on that.

You can take a hash of all pci devices present. Pretty much locks it to the computer or any identical computer (which is only not good in companies, but I don't think they'll use your software too much).

You can take the MAC addresses of any network card. Preferable would be an onboard NIC, but that is probably nearly impossible to detect.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 11:29 pm
by Ryu
Candy wrote: You can hash the bios: read from /dev/mem between 0xF0000 and 0xFFFFF and calculate a hash. It should probably work between 0xFFFF0000 and 0xFFFFFFFF as well. The first is the shadow (so it might be overwritten, but I doubt anybody would overwrite their bios shadow for using your game). This includes some hardware info so you're locked onto that specific configuration. The 0xFFFF0000 location probably doesn't contain that information, but I'm not sure on that.
I'm not sure about that since two of the same boards can have the same BIOS image and the same with PCI devices which is possible to have two computers to be identical in every device.

MAC on NICs is okay, however the NICs that I have worked with, its possible to change the MAC on the serial EEPROM, and whatif there is no NIC? Nothing serious but worth noting here.

Re:Obtaining Hardware Serial Numbers

Posted: Wed May 10, 2006 11:57 pm
by Brendan
Hi,
jitspoe wrote:This is actually for a game I'm developing. Somebody suggested I ask in here. I want to be able to have hardware-level bans like punkbuster uses, because there have been instances where cheaters use dynamic ip's or proxies to evade bans.
What you want is DRM - the "trusted computing" chip introduced recently...

For BIOS checksums, ethernet card addresses, etc your cheaters can run the game under an emulator (VMware, VirtualPC, Qemu, etc) and change the emulated hardware when they like.

If it's a specific game (rather than a generic game engine), I'd consider a single player (offline) "tutorial" thing. The idea is that to create an online login you'd have to collect 4 hours of experience in single player mode. That way new users don't get owned as soon as they connect (and don't ask so many newbie questions), and cheaters would be forced to go through a 4 hour tutorial each time they're banned before they can get a new username/password - it'd be too annoying to do often. I guess it also depends on the type of game too - for a role playing game or a military thing it'd work, but for "multiplayer tetris" it'd suck...


Cheers,

Brendan

Re:Obtaining Hardware Serial Numbers

Posted: Thu May 11, 2006 2:29 pm
by mystran
Try: "/sbin/hdparm -i /dev/hda" (you probably need root).

Try: "/bin/hostid" (any user)

You can look at source of hostid and see how it works.

On Pentium3 (only) you also get CPU serial number with CPUID instruction, and you don't need to be in kernel for that.

There are probably more, ofcourse, but those I could immediately think of.

Re:Obtaining Hardware Serial Numbers

Posted: Thu May 11, 2006 4:18 pm
by Pype.Clicker
jitspoe wrote: This is actually for a game I'm developing.
Okay ... now the question is how can you make sure the "bad guys" really use your program. Nothing prevents me from crafting a program that sends you a random number where i'm supposed to send the computer ID, right (i mean technically, except the fact i'm a good guy ;D)