Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fool a site that looks at the JavaScript object 'navigator' to see that I'm not on Windows?

Tags:

I am trying to browse a website, however, it only works under Windows and Mac because they use the navigator.platform from JavaScript to find out the architecture I am running on. Of course, they also use the browser's user agent, but that was easy to spoof.

Here is the .js in question: http://pastebin.com/f56fd608d. The code responsible for browser detection is at the top. Is there any way of changing the .js file before the site runs, or something similar, so I can eliminate the check?

Using the JavaScript console yields:

>navigator.platform
Linux i686

Evidently I changed the browser's user agent, but navigator.platform does not seem to take it's value from the user agent.

Maybe someone knows how to change the value returned by navigator.platform, because I hate running Windows under VirtualBox to use this site.

EDIT: This could be of interest because Linux users might be artificially denied access to websites, and can do nothing about it.

like image 871
Radu Avatar asked Jan 30 '10 02:01

Radu


People also ask

How does browser recognize JavaScript code?

JavaScript has a standard object called navigator that contains data about the browser being used. The navigator object has a lot of properties, but the . userAgent property — a string that contains data about the browser, operating system, and more– is all we'll need.

What is the use of navigator object in JavaScript?

The navigator object contains information about the browser. The location object is a property of the window object.

What is Window navigator in JavaScript?

The JavaScript navigator object is used for browser detection. It can be used to get browser information such as appName, appCodeName, userAgent etc. The navigator object is the window property, so it can be accessed by: window. navigator.

How can you detect the client's browser name in JavaScript?

Answer: To establish the actual name of the user's Web browser, you can use the navigator. appName and navigator. userAgent properties. The userAgent property is more reliable than appName because, for example, Firefox or Opera may return the string "Netscape" as the value of navigator.


1 Answers

var fakePlatformGetter = function () {   return "your fake platform"; }; if (Object.defineProperty) {   Object.defineProperty(navigator, "platform", {     get: fakePlatformGetter   });   Object.defineProperty(Navigator.prototype, "platform", {     get: fakePlatformGetter   }); } else if (Object.prototype.__defineGetter__) {   navigator.__defineGetter__("platform", fakePlatformGetter);   Navigator.prototype.__defineGetter__("platform", fakePlatformGetter); } 
like image 167
Eli Grey Avatar answered Oct 05 '22 11:10

Eli Grey