-2

Is there a way to get a unique serial number for machines such as Mac,Windows and devices such as iPhone,Blackberry using php/javascript?

user475685
  • 6,921
  • 7
  • 24
  • 24
  • What is the purpose of this SN? What does it mean such as Mac, Windows, etc.? – fabrik Mar 10 '11 at 08:58
  • You mean the machine MAC address (http://en.wikipedia.org/wiki/MAC_address) or just random unique number like GUID? – Shadow The Vaccinated Wizard Mar 10 '11 at 08:59
  • Also, is this for public website or something like intranet or trusted site? – Shadow The Vaccinated Wizard Mar 10 '11 at 09:14
  • using javascript/php i need system unique information to create a unique user id. – user475685 Mar 10 '11 at 09:34
  • @user475685 friendly advice: don't go this way. You will find out that it's a dead end, sooner or later. Instead, do the sensible thing: generate the user ID in server side code, simple way is generating big random number (e.g. in range 1000000000-9000000000) and keep generating as long as the number is already taken. If you go this way feel free to edit your question with your new request and we'll give you more options. – Shadow The Vaccinated Wizard Mar 10 '11 at 11:52

4 Answers4

1

It really requires at least one reference datum - javascript can't read things like IP addresses or MAC addresses - so that's ruled out. There are implementations of uuid for PHP - but to create a valid one, you need a real IP address assigned.

And if have code deployed serverside, its straightforward to implement a counter based system.

symcbean
  • 45,607
  • 5
  • 49
  • 83
1

What is a machine?

Machines are made from parts, so determining wether a machine is still the same can be a philosophical question in its own right.

For example a computer's hard drive probably has a unique serial number, if the machine has a network card, it has a unique MAC-Address, and it might even be considered a "different machine" when running a different operating systems (Windows, Mac, etc). All those unique IDs can be mungled together to create a unique machine-ID, and this is exactly what some software vendors such as Mathematica do to make sure you don't run the software on a machine or an operating system, you have not licensed it for.

Using Interface Identifiers

With IPv6 finally becoming widely available, the Interface identifier of the protocol can serve as an identifier of your machine (or at least its network card), since it contains the MAC-address of the network card. IPv6 provides privacy extensions to prevent this kind of identification, since in the age of personal computers and mobile devices machine identification equals user identification, which is a huge privacy issue. Currently, Apple and Android mobile devices, don't provide privacy extension, and they are deactivated on Mac and Linux by default. Only Windows 7 seems to have them enabled by default.

Accessing the IP address in PHP and javascript

  • In PHP it's pretty simple to access the IP address via $_SERVER['REMOTE_ADDR']
  • In javascript you could issue a JSONP request to a server that returns the user's IP address.

See: Can I perform a DNS lookup (hostname to IP address) using client-side Javascript?

Accessing the MAC address in Javascript

Even if the machine only has IPv4 - there is a proof of concept hack (http://samy.pl/mapxss/) that retrieves the MAC address from some routers via javascript XSS. The MAC address of your router is then sent to the google geolocation service to identify the machine's exact location. (Of course this only is a weak identifier for mobile devices)

Combining Identifiers

Webbrowsers will provide you with a useragent string, that can make your identifier even "more unique", and then there are cookies, geolocation services etc.

While none of these techniques provide a way to create a 100% unique identifier, several of those techniques combined can provide a very high accuracy of identificiation. Even if parts of a machine are changed, you might be able to re-identify it, when applying an array of identification techniques. Also note that when using browser identification etc, you may face the problem of over-identification, especially if a machine is using more than one browser to access your service.

Asking the user

Due to potential privacy issues, you should consider using an opt-in approach for creating the unique id. Also since it's the users who are in touch with their machines, they are the only ones who can uniquely identify their machine with a 100% certanity. So the best thing is to provide an incentive to the user to trust you with identifying their machines. A simple scenario, would be to provide the user with a login (so you have user identification) and then ask the user to help you with machine identification. Of course this only works if you trust your user, but if you don't, they should probably not trust you either.

Community
  • 1
  • 1
codecraft
  • 1,123
  • 9
  • 11
0

What is a machine?

Machines are made from parts, so determining wether a machine is still the same can be a philosophical question in its own right.

For example a computer's hard drive probably has a unique serial number, if the machine has a network card, it has a unique MAC-Address, and it might even be considered a "different machine" when running a different operating systems (Windows, Mac, etc). All those unique IDs can be mungled together to create a unique machine-ID, and this is exactly what some software vendors such as Mathematica do to make sure you don't run the software on a machine or an operating system, you have not licensed it for.

Using Interface Identifiers

With IPv6 finally becoming widely available, the Interface identifier of the protocol can serve as an identifier of your machine (or at least its network card), since it contains the MAC-address of the network card. IPv6 provides privacy extensions to prevent this kind of identification, since in the age of personal computers and mobile devices machine identification equals user identification, which is a huge privacy issue. Currently, Apple and Android mobile devices, don't provide privacy extension, and they are deactivated on Mac and Linux by default. Only Windows 7 seems to have them enabled by default.

madara
  • 1
  • 1
0

No, there is no way to do that.

This is a good thing, since it makes it harder to track people via websites.

Privacy is precious ;)

Martin hurries off to delete all his cookies and put on his tinfoil hat

Martin Jespersen
  • 23,663
  • 6
  • 52
  • 66