问题
I was wondering if it is allowed to fake the user agent to pretend that me script is safari or any other browser? Can I get into trouble if I faked the user agent in my script? I don't mean a custom one such as "My Script", I mean a user agent which belongs to a browser like "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11"?
回答1:
I'd say it depends on the context. It might be considered illegal if you are trying to gain unauthorized access to information by manipulating the user-agent HTTP header. This same principle could also apply to manipulating Cookie HTTP header. In this context, the prosecutor may label it as "hacking".
When Andrew Alan Escher Auernheimer (known as Weev), was recently prosecuted and convicted of "hacking" AT&T's website, the prosecutors kept repeating over and over that his "spoofing" of an iPad (via a forged User-Agent header) was an indication of malicious/devious intent. I'm not sure if those same prosecutors would say such spoofing is outright illegal just on its own, but it was part of what got him convicted, so that should definitely be taken into consideration.
If you're going to fake user agent let's say to debug how a site will be displayed on an iPad, this is not illegal. Browser vendors such as Chrome, Internet Explorer has now a feature to modify the user agent right inside the browser!
来源:https://stackoverflow.com/questions/20926097/is-using-a-faked-user-agent-allowed