views:

729

answers:

3

I know, that this question was created many times, but it is stil open

The problem is following:

My application need to generate some UID for computer, it working on. I need it to implement the genuine protection.

MAC address is a good candidate, because it is unique for each ethernet card.

Many articles uses either GetAdaptersInfo, WMI, NetBIOS or Sockets.

Here is one of them: Three ways to get your MAC address.

They, shore, return a MAC address, but this address can be set by hands from adapter properties

Control Panel > Network and Internet > Network and Sharing Center > Change Adatper Settings > right click on adapter > Properties > click "configure" button > go to "Advanced" tab > chose "Network Address" and change it

The all mentioned methods are not match my needs, because a MAC address, being set with driver has greater priority, than true hardware MAC address. This "fake" address will be returned by all Win API functions, that i know, and therefore, the genuine protection can easy be broken.

Any help from you, guys, will be greatly appreciated.

Thanks.

A: 

I don't think "Network Address" you mention refers to the MAC address. Some devices allow you to "spoof" the MAC address for ISP purposes, but you should be able to get the real MAC using the methods you found.

Dave Swersky
Network Address - is a MAC address, because all of the methods returns the value of what i entered into this field
AntonAL
Hmm that's strange, the MAC address of a physical device is supposed to be burned in...
Dave Swersky
+6  A: 

The only means that Windows has to access the MAC address is asking the driver.

That's what the driver is for - to talk to the hardware so that Windows doesn't have to include code for every single device anyone might come up with ever.

If the driver is telling Windows that the MAC address is something, then that's what the MAC address is.

Anon.
I just did some poking around on my PC, and discovered that I cannot change the MAC address using the method OP describes, so I suspect that the ability for it to "change" depends on the driver, and likely on the network adapter with the MAC interface.
sheepsimulator
It's not that simple though. The driver would presumably be an Ethernet driver. But for higher-level protocols like IP, ARP needs to be supported, and that requires the true MAC. If the ARP message sent included a "only for the OS" MAC, other computers would use that, and the Ethernet card wouldn't pick it up.
MSalters
You could fix that by setting the device to promiscuous mode and looking for the "spoofed" MAC in the packets you see.
Anon.
I noticed, that when i don't touch the MAC address by hands in adapter preferences (switch Network Address to "Not present"), than all the WinAPI functions, mentioned above, will return MAC address, burned into hardware.I think, following steps must be done programmatically:1. Store current MAC address, altered by hands2. Somehow, set programmatically "Not present" state of MAC address3. Possible, restart NIC4. Use methods of getting MAC address, described in mentioned topics5. Set stored address back6. Possible, restart NICBut what about step 2 ?
AntonAL
+1  A: 

MAC address is a good candidate, because it is unique for each ethernet card.

I'm afraid not. Firstly, I've read reports of customers receiving entire batches of machines with identical MAC addresses (apparently this causes pain when building clusters).

I have also seen with my own eyes a machine that changes its MAC address on reboot. Every time. It was an old IBM Thinkpad running Windows XP.

My advice: stay well away from MAC addresses if you're generating unique IDs.

Duncan Bayne