Is there a way to get a unique serial number for machines such as Mac,Windows and devices such as iPhone,Blackberry us开发者_如何学JAVAing php/javascript?
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.
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.
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
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.
精彩评论