Obtaining Hardware Serial Numbers

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jitspoe

Obtaining Hardware Serial Numbers

Post 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.
paulbarker

Re:Obtaining Hardware Serial Numbers

Post 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.
jitspoe

Re:Obtaining Hardware Serial Numbers

Post 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.
paulbarker

Re:Obtaining Hardware Serial Numbers

Post 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.
jitspoe

Re:Obtaining Hardware Serial Numbers

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Obtaining Hardware Serial Numbers

Post 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.
Ryu

Re:Obtaining Hardware Serial Numbers

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Obtaining Hardware Serial Numbers

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
mystran

Re:Obtaining Hardware Serial Numbers

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Obtaining Hardware Serial Numbers

Post 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)
Post Reply