LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to get serial numbers? (https://www.linuxquestions.org/questions/programming-9/how-to-get-serial-numbers-570743/)

G00fy 07-19-2007 12:56 PM

How to get serial numbers?
 
No :) This is not a warez/crackz/serialz question :p.

I am searching how I can uniquely identify a computer. I want to use it in a program I'm making to see which computer is talking to me (once send a hash of those, and then I know who it is).

What I was thinking of were the following items:
- CPU type, speed + CPUID (if present).
- Memory type, serials (if present)
- Harddrive type + serials (if present).
- Mainboard type + serials (if present).

But does anyone know how to get those?

At windows I can find out my cputype(--serial) + memory type(++serial)
At linux I can find out my cputype(--serial) + harddrives


Where could i start looking? Is there some program which implements those features already?


Thanks a lot!

macemoneta 07-19-2007 01:03 PM

Take a look at dmidecode. For example, as root:

dmidecode > dmi.txt

theNbomr 07-19-2007 01:18 PM

If your requirement is to communicate these numbers using ethernet, then the ethernet MAC should, itself, be unique enough. For TCP/IP based communications, each host should be caching these in its own arp table. On a linux host, you can dump this table using the arp command.
Other than recent Intel CPUs having a CPU-ID, I don't think there is any standard way of uniquely identifying a host. The ethernet MAC was contrived to solve this problem, although there is no guarantee that any given host has one & only one such number, or even that they are absolutely unique (disreputable vendors have produced ethernet hardware with non-unique MACs).
--- rod.

bulliver 07-19-2007 01:57 PM

Quote:

Other than recent Intel CPUs having a CPU-ID, I don't think there is any standard way of uniquely identifying a host. The ethernet MAC was contrived to solve this problem, although there is no guarantee that any given host has one & only one such number, or even that they are absolutely unique (disreputable vendors have produced ethernet hardware with non-unique MACs).
Also keep in mind that if you are in a hostile environment the MAC can be trivially spoofed.

macemoneta 07-19-2007 02:10 PM

Quote:

The ethernet MAC was contrived to solve this problem
Uh, no. The Ethernet MAC is a layer 2 identifier for packets, used to control packet routing. It's mapped to/from an IP address by the ARP protocol. It has nothing to do with identifying a PC, and in fact it exists only on the local LAN segment (so it doesn't even need to be unique, except on that LAN segment).

b0uncer 07-19-2007 02:12 PM

Quote:

Also keep in mind that if you are in a hostile environment the MAC can be trivially spoofed.
And if you based the identification on some numbers about certain pieces of hardware, one could easily switch some part of hardware (for example ethernet cards don't pay much) and the identification would change.

There's no sure way to identify a computer, and I don't think there should be. It's like implanting a chip into your head to identify you. Then somebody figures out how to cheat, and suddenly you've done something you didn't ;)

theNbomr 07-19-2007 02:33 PM

Quote:

Originally Posted by macemoneta
Uh, no. The Ethernet MAC is a layer 2 identifier for packets, used to control packet routing. It's mapped to/from an IP address by the ARP protocol. It has nothing to do with identifying a PC, and in fact it exists only on the local LAN segment (so it doesn't even need to be unique, except on that LAN segment).

You misunderstood my meaning. For ethernet to work, a destination host/interface must be uniquely identified, since that is the only way an ethernet interface knows which nonbroadcast packets are destined for it. The MAC serves this purpose. MACs exist on all ethernet LANs, by definition. I did not intend to say that the MAC was intended to serve any higher purpose than to identify source & desination hosts on a LAN. According to the IEEE 802.3, MACs are supposed to be unique, although you are correct that in practice, this need only apply to interfaces on a single LAN, roughly speaking (ethernet bridges pass MACs between segments).
--- rod.

G00fy 07-19-2007 02:34 PM

Thank you for your answers so far! the dmidecode looks promising, although it doens't give me the same things as cpu-z under windows (like it cannot identify my memory). Maybe cpu-z is collecting magic numbers and then recognizing these to say which memory is what and stuff like that.

Oh, the environment is absolutely not hostile at all... It's just that I once send a huge batch from the client -> server with all kinds of data and then send a hash back, which uniquely defines that machine. In all later communications this hash is used (until some hardware components change). And that's exactly the issue ;-). I HAVE to know it when hardware changes. So basically that's a change of mobo, cpu, drives and memory. The rest is of less importance.

Is there another tool than dmidecode which also provides me with similar information? (I checked out Todd Allen's cpuid & also browsed through the /proc dir), but maybe you guys (and mayhaps you girls) have another bright idea? :D


Thanks!

brianmcgee 07-19-2007 03:04 PM

If you need to track also hardware modifications maybe you should have a look at how system profiles for the Red Hat Network are generated:

At first, following information is gathered from the system:

Red Hat Linux version, Hostname, IP address, CPU model, CPU speed, Amount of RAM, PCI devices, Disk sizes.

Then a hash value is calculated from that information to generate a unique serial.

But maybe you can also use the ssh-host-keys that were generated during first boot of your system.


All times are GMT -5. The time now is 07:26 AM.