Browser Fingerprint/Deviceprint
Description: This function uses the navigator.useragent object to fingerprint the browser that the client's device is utilizing.
Issues: Due ease at which users can alter their user-agent via a number of browser add-ons the output should not be taken at face value. Other methods should be used in conjunction with this function to determine its accuracy.
Returns: Browser name and version number.
Entropy: TBD
Output for your computer is:
function fingerprint_browser() { "use strict"; var strOnError, strUserAgent, numVersion, strBrowser, strOut; strOnError = "Error"; strUserAgent = null; numVersion = null; strBrowser = null; strOut = null; try { strUserAgent = navigator.userAgent.toLowerCase(); if (/msie (\d+\.\d+);/.test(strUserAgent)) { //test for MSIE x.x; numVersion = Number(RegExp.$1); // capture x.x portion and store as a number if (strUserAgent.indexOf("trident/6") > -1) { numVersion = 10; } if (strUserAgent.indexOf("trident/5") > -1) { numVersion = 9; } if (strUserAgent.indexOf("trident/4") > -1) { numVersion = 8; } strBrowser = "Internet Explorer " + numVersion; } else if (strUserAgent.indexOf("trident/7") > -1) { //IE 11+ gets rid of the legacy 'MSIE' in the user-agent string; numVersion = 11; strBrowser = "Internet Explorer " + numVersion; } else if (/firefox[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Firefox " + numVersion; } else if (/opera[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Opera/x.x or Opera x.x (ignoring remaining decimal places); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Opera " + numVersion; } else if (/chrome[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Chrome/x.x or Chrome x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Chrome " + numVersion; } else if (/version[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Version/x.x or Version x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Safari " + numVersion; } else if (/rv[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for rv/x.x or rv x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Mozilla " + numVersion; } else if (/mozilla[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Mozilla/x.x or Mozilla x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Mozilla " + numVersion; } else if (/binget[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for BinGet/x.x or BinGet x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (BinGet) " + numVersion; } else if (/curl[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Curl/x.x or Curl x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (cURL) " + numVersion; } else if (/java[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Java/x.x or Java x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (Java) " + numVersion; } else if (/libwww-perl[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for libwww-perl/x.x or libwww-perl x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (libwww-perl) " + numVersion; } else if (/microsoft url control -[\s](\d+\.\d+)/.test(strUserAgent)) { //test for Microsoft URL Control - x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (Microsoft URL Control) " + numVersion; } else if (/peach[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for Peach/x.x or Peach x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (Peach) " + numVersion; } else if (/php[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for PHP/x.x or PHP x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (PHP) " + numVersion; } else if (/pxyscand[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for pxyscand/x.x or pxyscand x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (pxyscand) " + numVersion; } else if (/pycurl[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for pycurl/x.x or pycurl x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (PycURL) " + numVersion; } else if (/python-urllib[\/\s](\d+\.\d+)/.test(strUserAgent)) { //test for python-urllib/x.x or python-urllib x.x (ignoring remaining digits); numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Library (Python URLlib) " + numVersion; } else if (/appengine-google/.test(strUserAgent)) { //test for AppEngine-Google; numVersion = Number(RegExp.$1); // capture x.x portion and store as a number strBrowser = "Cloud (Google AppEngine) " + numVersion; } else { strBrowser = "Unknown"; } strOut = strBrowser; return strOut; } catch (err) { return strOnError; } }