This is interesting. Ever wondered why all the User-Agents start with Mozilla? please read on...
What is User-Agent?
When you browse a web page via your browser, the browser sends this particular string called User-Agent along with other request headers. Below is the definition for User-Agent from Mozilla developers.
The User-Agent request header is a characteristic string that lets servers and network peers identify the application, operating system, vendor, and/or version of the requesting user agent.
What is the need for User-Agent? In HTTP, the User-Agent string is often used for content negotiation, where the origin server selects suitable content or operating parameters for the response. For example, the User-Agent string might be used by a web server to choose variants based on the known capabilities of a particular version of client software. The concept of content tailoring is built into the HTTP standard in RFC 1945 "for the sake of tailoring responses to avoid particular user agent limitations.”. User-Agent is used to identify webcrawlers which uses the respective spiderbot name in their User-Agent. The other reason is for sniffing the client browser, for business gains which the below content is all about.
A typical User-Agent string looks like this (which can be found by checking your browser's request headers in developer tools or by hitting F12 and checking the Request headers in Headers section):
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0
The UA(User-Agent) string definition by Mozilla team is as follows :
Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion 1 Mozilla/5.0 is the general token that says the browser is Mozilla-compatible. For historical reasons, almost every browser today sends it. Mobile — the web is the platform. Note that platform can consist of multiple "; "-separated tokens. See below for further details and examples. 20100101.)
And if we check the same on a Google-Chrome browser this is what we get, and why on earth does it say Safari and Gecko:
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
So why do all these User-Agent string start with Mozilla?
It follows a historical reason as mentioned by the Mozilla team in the above definition and the history goes like this...
Even though Tim Berners Lee's WorldWideWeb is the first web client/browser, the popularity explosion happened with NCSA Mosaic which was a graphical browser (with pictures along with text) running originally on Unix and Mosaic called itself NCSA_Mosaic/2.0 (Windows 3.1)
Marc Andreessen, who was the leader of the Mosaic team at NCSA, quit to form a company that would later be known as Netscape Communications Corporation. Netscape released its flagship Navigator product in October 1994, and it took off the next year.
The Netscape web browser did not use any NCSA Mosaic code. The internal codename for the company's browser was Mozilla, which stood for "Mosaic killer", as the company's goal was to displace NCSA Mosaic as the world's number one web browser. This codename they incorporated as their User-Agent header Mozilla/1.0.Microsoft, which had thus far not marketed a browser, finally entered the arena with its Internet Explorer product (version 1.0 was released 16 August 1995), purchased from Spyglass, Inc. This began what is known as the "browser wars" in which Microsoft and Netscape competed for the Web browser market.
Why the user-agent along with header? because at that time the “user agent sniffing” is done by webmasters to give the features to the particular browser request and not to other. Mozilla/Netscape2.0 had many cool features back then like frames, java, plugins etc., and to “Mozilla” user-agent's webmasters sent frames, but to other browsers they sent not frames. Guess what these browsers were not free at that time :)
When user-agent sniffing was the need of the hour, to get the features from Webmasters like frames, a feature supported by both Netscape and IE, but not other browsers of the era, IE spoofed the Mozilla string into their UA.
Unable to continue commercially funding their product's development, Netscape responded by open sourcing its product, creating Mozilla. The Mozilla Organization rewrote the entire browser's source code based on the Gecko rendering engine, and all future Netscape releases were based on this rewritten code.
- Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.2) Gecko/20040825 Camino/0.8.1
- Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.8) Gecko/20071008 SeaMonkey/1.0
each pretending to be Mozilla, and all of them powered by Gecko.
Konquerer browser which comes with Linux distros, used KHTML rendering engine, but it was not Gecko, and to get the Gecko tag (for browser sniffers) in UA string it appended “like Gecko” to render good pages like that of Gecko.
Mozilla/5.0 (compatible; Konqueror/3.2; FreeBSD) (KHTML, like Gecko)
Apple built Safari, and used KHTML, and added many features, by forkingthe project, and called it AppleWebKit, but wanted pages written for KHTML, so the spoofing continues by appending KHTML string along with Webkit.
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/85.7 (KHTML, like Gecko) Safari/85.5,
Then comes the Chrome with much spoofing, which used the Webkit engine and wanted to get the pages build for Safari, here is that great impersonation with AppleWebKit and Safari tag:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
The bottom-up approach of this spoofing/impersonations goes like this:
Chrome used WebKit, and pretended to be Safari(AppleWebKit), and WebKit pretended to be KHTML(KHTML), and KHTML pretended to be Gecko (like Gecko), and all browsers pretended to be Mozilla (Mozilla)
Are you building a web-browser? If so, please follow the above mess !!
References:

No comments:
Post a Comment