Serial Number?
-
Can I access the serial number of the machine my app is running
on? I want to write an encryption scheme based on this. Since
the files won't be moving from machine to machine, this sounds like
a logical way of doing it. Maybe I can factor in username...
Hrmm. Anyhoo, any help would be appreciated.
Erik -
'ioreg -l -w 0' is your friend.
Look for the property named 'serial-number' which appears here
(trimmed down output):
+-o Root <class IORegistryEntry>
+-o PowerMac3,5 <class IOPlatformExpertDevice>
| {
| "copyright" = <"Copyright 1983-2001 Apple Computer, Inc. All
Rights Reserved">
| "serial-number" = <"KSD0100519144XB1360PW1234123412341234">
| "IOBusyInterest" = ("_IOServiceInterestNotifier is not
serializable")
| "system-id" = <"0000000000000">
| "#size-cells" = <00000001>
| "compatible" = <"PowerMac3,5","MacRISC2","MacRISC","Power
Macintosh">
| "AAPL,add-fcode-file" = <ff85c750>
| "scb#" = <00000000>
| "color-code" = <ff11>
| "AAPL,phandle" = <ff87a590>
| "name" = <"device-tree">
| "model" = <"PowerMac3,5">
| "#address-cells" = <00000001>
| "IOPlatformArgs" = <00675000006740000000000000000000>
| "IONWInterrupts" = "IONWInterrupts"
| "clock-frequency" = <07efdc44>
| "powertreedesc" = ({"service"="IOPMUSBMacRISC2 is not
serializable","children"=({"service"="IOPCIDevice is not
serializable","ch$
| "device_type" = <"bootrom">
| "customer-sw-config" = <" ">
| }
|
Note that the serial number displayed by the finder consists of two
portions of the serial-number string shown above.
-tim
On Thursday, October 11, 2001, at 04:57 PM, Erik Thorteran wrote:> Can I access the serial number of the machine my app is running on? I
> want to write an encryption scheme based on this. Since the files
> won't be moving from machine to machine, this sounds like a logical way
> of doing it. Maybe I can factor in username... Hrmm. Anyhoo, any
> help would be appreciated.
>
> Erik
>
> _______________________________________________
> MacOSX-dev mailing list
> <MacOSX-dev...>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev -
Aren't there quite a few macs out there that don't have serial numbers?
Ack, at 10/11/01, Timothy J. Wood said:> 'ioreg -l -w 0' is your friend.
>
> Look for the property named 'serial-number' which appears here
> (trimmed down output):
>
> +-o Root <class IORegistryEntry>
> +-o PowerMac3,5 <class IOPlatformExpertDevice>
> | {
> | "copyright" = <"Copyright 1983-2001 Apple Computer, Inc. All
> Rights Reserved">
> | "serial-number" = <"KSD0100519144XB1360PW1234123412341234">
> | "IOBusyInterest" = ("_IOServiceInterestNotifier is not serializable")
> | "system-id" = <"0000000000000">
> | "#size-cells" = <00000001>
> | "compatible" = <"PowerMac3,5","MacRISC2","MacRISC","Power Macintosh">
> | "AAPL,add-fcode-file" = <ff85c750>
> | "scb#" = <00000000>
> | "color-code" = <ff11>
> | "AAPL,phandle" = <ff87a590>
> | "name" = <"device-tree">
> | "model" = <"PowerMac3,5">
> | "#address-cells" = <00000001>
> | "IOPlatformArgs" = <00675000006740000000000000000000>
> | "IONWInterrupts" = "IONWInterrupts"
> | "clock-frequency" = <07efdc44>
> | "powertreedesc" = ({"service"="IOPMUSBMacRISC2 is not
> serializable","children"=({"service"="IOPCIDevice is not
> serializable","ch$
> | "device_type" = <"bootrom">
> | "customer-sw-config" = <" ">
> | }
> |
>
> Note that the serial number displayed by the finder consists of
> two portions of the serial-number string shown above.
--
Sincerely,
Rosyna Keller
Technical Support/Holy Knight/Always needs a hug
Unsanity: Unsane Tools for Insane People -
> Aren't there quite a few macs out there that don't have serial numbers?
I know mine doesn't: B&W G3 (1998) ...at least not that will show up
with that command.
-rick -
The Ethernet address is often used if you need a unique hardware-based
number. Quite a few Macs have Ethernet :-). There's also a UUID
function in Core Foundation for generating a unique ID number.
On Thursday, October 11, 2001, at 06:20 PM, Rick Sanford wrote:>> Aren't there quite a few macs out there that don't have serial
> numbers?
>
> I know mine doesn't: B&W G3 (1998) ...at least not that will show up
> with that command. -
And how do you get the Ethernet address?
Erik
On Thursday, October 11, 2001, at 07:44 PM, Paul Collins wrote:> The Ethernet address is often used if you need a unique
> hardware-based number. Quite a few Macs have Ethernet :-).
> There's also a UUID function in Core Foundation for generating a
> unique ID number.
> On Thursday, October 11, 2001, at 06:20 PM, Rick Sanford wrote:
>
>>> Aren't there quite a few macs out there that don't have serial
>> numbers?
>>
>> I know mine doesn't: B&W G3 (1998) ...at least not that will show
>> up with that command.
> _______________________________________________
> MacOSX-dev mailing list
> <MacOSX-dev...>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev -
However the MAC address can be changed and is not guaranteed to be
unique as it can it be changed by the user.
Ack, at 10/11/01, Paul Collins said:> The Ethernet address is often used if you need a unique
> hardware-based number. Quite a few Macs have Ethernet :-). There's
> also a UUID function in Core Foundation for generating a unique ID
> number.
--
Sincerely,
Rosyna Keller
Technical Support/Holy Knight/Always needs a hug
Unsanity: Unsane Tools for Insane People -
On Thursday, October 11, 2001, at 07:52 , Erik Thorteran wrote:> And how do you get the Ethernet address?
>
> Erik
Keep in mind that it is very easy to change a computer's ethernet
address. (I think ifconfig can even do this, though I'm not sure at the
moment.)
That said, I found the following BSD code when I attacked this problem
last year. It worked pretty much as written. It was submitted to the
"libnet" project <http://www.packetfactory.net/libnet/> by somebody
named Dug Song <dugsong...>.
-g
--
struct ether_addr *
libnet_get_hwaddr(struct libnet_link_int *l, const char *device, char
*ebuf)
{
int mib[6];
size_t len;
char *buf, *next, *end;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
struct ether_addr *ea = NULL;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
mib[5] = 0;
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
{
return (NULL);
}
if (!(buf = (char *)malloc(len)))
{
return NULL;
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0)
{
free(buf);
return (NULL);
}
end = buf + len;
for (next = buf ; next < end ; next += ifm->ifm_msglen)
{
ifm = (struct if_msghdr *)next;
if (ifm->ifm_type == RTM_IFINFO)
{
sdl = (struct sockaddr_dl *)(ifm + 1);
if (strncmp(&sdl->sdl_data[0], device, sdl->sdl_nlen) == 0)
{
if (!(ea = malloc(sizeof(struct ether_addr))))
{
return (NULL);
}
memcpy(ea->ether_addr_octet, LLADDR(sdl),
ETHER_ADDR_LEN);
break;
}
}
}
free(buf);
return (ea);
} -
On Thursday, October 11, 2001, at 07:52 PM, Erik Thorteran wrote:> And how do you get the Ethernet address?
Sorry, I don't know. There must be a unix way, and probably also a
Carbon way. I checked a couple of man pages but couldn't find anything,
except you can display it with netstat -rn. And I wasn't aware that the
address could be changed--I thought it was fixed in hardware (MAC
addresses can be used to determine the manufacture of the Ethernet
hardware interface, or so I've heard). -
FYI: Mac serial numbers are not guaranteed to be unique. From what I
can tell from your email you want to base your encryption on
something unique within the system. Generally the recommended way to
do what you want is to use the MAC address of the machine.
There is information on getting 'supposedly unique' information on
your system at the URL below:
http://developer.apple.com/technotes/tn/tn1103.html
If you really want the serial number (and nothing else) you can use
the IOKit/IOKitLib.h API's to pull the serial number.> Can I access the serial number of the machine my app is running--
> on? I want to write an encryption scheme based on this. Since
> the files won't be moving from machine to machine, this sounds like
> a logical way of doing it. Maybe I can factor in username...
> Hrmm. Anyhoo, any help would be appreciated.
>
> Erik
*******************************************************
Chad Jones
Engineer, Hardware & Networking group
Worldwide Developer Technical Support
Apple Computer, Inc. email: <chadj...>
1 Infinite Loop, MS: 303-2T phone: (408) 974-8106
Cupertino, CA 95014 fax: (408) 862-7602
******************************************************* -
ifconfig en0 will display most information about the interface named en0.
If you're just looking for the ethernet address, pipe the output of
ifconfig en0 to grep with keyword ether (which is the variable that
stores the ethernet address), like so:
ifconfig en0 | grep ether
You should get output like this:
ether 00:AA:BB:CC:DD:EE
There is a leading tab.
It's very easy to change your ethernet address, at least with the BSD
variants I've used:
sudo ifconfig ether 00:00:AA:BB:CC:DD
That's it.
On Thu, 11 Oct 2001, Paul Collins wrote:>
> On Thursday, October 11, 2001, at 07:52 PM, Erik Thorteran wrote:
>
>> And how do you get the Ethernet address?
>
> Sorry, I don't know. There must be a unix way, and probably also a
> Carbon way. I checked a couple of man pages but couldn't find anything,
> except you can display it with netstat -rn. And I wasn't aware that the
> address could be changed--I thought it was fixed in hardware (MAC
> addresses can be used to determine the manufacture of the Ethernet
> hardware interface, or so I've heard).
> _______________________________________________
> MacOSX-dev mailing list
> <MacOSX-dev...>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev
> -
> -----Original Message-----
> From: Chad Jones [mailto:<chadj...>]> FYI: Mac serial numbers are not guaranteed to be unique. From what I
> can tell from your email you want to base your encryption on
> something unique within the system. Generally the recommended way to
> do what you want is to use the MAC address of the machine.
Shouldn't one be careful with that, too?
I know of Ethernet cards in the Wintel world that support manual re-setting
the MAC address. I don't know if any of those would work on the Mac, though.
_____________________________________
Jens Baumeister
Bullex GmbH, Cologne, Germany
She sells c-shells by the sea shore. -
On vendredi, octobre 12, 2001, at 05:55 , Chad Jones wrote:> FYI: Mac serial numbers are not guaranteed to be unique. From what I
> can tell from your email you want to base your encryption on something
> unique within the system. Generally the recommended way to do what you
> want is to use the MAC address of the machine.
>
> There is information on getting 'supposedly unique' information on your
> system at the URL below:
> http://developer.apple.com/technotes/tn/tn1103.html
>
> If you really want the serial number (and nothing else) you can use the
> IOKit/IOKitLib.h API's to pull the serial number.
BTW, it could have been an interesting feature to be able to add some
keys with the SystemConfiguration Framework that would not be displayed
when you list all the available keys. To handle Serial Number. -
On Friday, October 12, 2001, at 05:11 am, Jens Baumeister wrote:> I know of Ethernet cards in the Wintel world that support manual
> re-setting
> the MAC address. I don't know if any of those would work on the Mac,
> though.
You can reset your MAC address on OS 9 by adding a resource to the
system file. No doubt there is a way of doing so on OS X, I just don't
know what it is :-)
-- Finlay


