Browser sniffer (renifleur)

Soyez le premier à donner votre avis sur cette source.

Snippet vu 14 826 fois - Téléchargée 29 fois

Contenu du snippet

A voir également

Ajouter un commentaire

Commentaires

GUIDARK
Messages postés
14
Date d'inscription
dimanche 2 janvier 2005
Statut
Membre
Dernière intervention
1 novembre 2008
-
Ok mais je vois pas l'intérêt de coder un tel script en js...
moi jdi vive le php
Matt 261
Messages postés
1173
Date d'inscription
mercredi 2 novembre 2005
Statut
Membre
Dernière intervention
10 septembre 2011
3 -
Salut,

un truc qui serait sympa, se serait de garder uniquement la valeur à True.

Voila
@+

Matt
cs_nathan
Messages postés
24
Date d'inscription
lundi 6 mai 2002
Statut
Membre
Dernière intervention
15 novembre 2005
-
tres bon script je l'utilise maintenant....
cs_Jackboy
Messages postés
757
Date d'inscription
vendredi 7 septembre 2001
Statut
Membre
Dernière intervention
19 juin 2008
-
Moi je trouve sa super, sa rassemble pas mal de script éparpillé sur plusieurs site, donc ces bien... peut etre modifier la fin du script (avec les url et tous), j'ai refais sa donc voici le script...


<html>
<head>
<script LANGUAGE= "JavaScript">

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();

// *** BROWSER VERSION ***

var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

// Note: On IE, start of appVersion return 3 or 4
// which supposedly is the version of Netscape it is compatible with.
// So we look for the real version further on in the string

var iePos = appVer.indexOf('msie');
if (iePos !=-1) {
is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
is_major = parseInt(is_minor);
}

// Netscape6 is mozilla/5 + Netscape6/6.0!!!
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
var nav6Pos = agt.indexOf('netscape6');
if (nav6Pos !=-1) {
is_minor = parseFloat(agt.substring(nav6Pos+10))
is_major = parseInt(is_minor)
}

var is_getElementById = (document.getElementById) ? "true" : "false"; // 001121-abk
var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); // new 020128- abk
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5); // new020128

var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 (is_nav && (is_major 2));
var is_nav3 (is_nav && (is_major 3));
var is_nav4 (is_nav && (is_major 4));
var is_nav4up = (is_nav && is_minor >= 4); // changed to is_minor for
// consistency - dmr, 011001
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
(agt.indexOf("; nav") != -1)) );

var is_nav6 = (is_nav && is_major==6); // new 010118 mhp
var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

var is_nav5 (is_nav && is_major 5 && !is_nav6); // checked for ns6
var is_nav5up = (is_nav && is_minor >= 5);

var is_ie = ((iePos!=-1) && (!is_opera));
var is_ie3 = (is_ie && (is_major < 4));

var is_ie4 (is_ie && is_major 4);
var is_ie4up = (is_ie && is_minor >= 4);
var is_ie5 (is_ie && is_major 5);
var is_ie5up = (is_ie && is_minor >= 5);

var is_ie5_5 = (is_ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
var is_ie5_5up =(is_ie && is_minor >= 5.5); // 020128 new - abk

var is_ie6 (is_ie && is_major 6);
var is_ie6up = (is_ie && is_minor >= 6);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened. Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

var is_aol = (agt.indexOf("aol") != -1);
var is_aol3 = (is_aol && is_ie3);
var is_aol4 = (is_aol && is_ie4);
var is_aol5 = (agt.indexOf("aol 5") != -1);
var is_aol6 = (agt.indexOf("aol 6") != -1);

var is_webtv = (agt.indexOf("webtv") != -1);

// new 020128 - abk

var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
var is_AOLTV = is_TVNavigator;

var is_hotjava = (agt.indexOf("hotjava") != -1);
var is_hotjava3 (is_hotjava && (is_major 3));
var is_hotjava3up = (is_hotjava && (is_major >= 3));

// end new


var is_js;
if (is_nav2 || is_ie3) is_js = 1.0;
else if (is_nav3) is_js = 1.1;
else if (is_opera6up) is_js = 1.4; // new 1.4? 020128 - abk
else if (is_opera5) is_js = 1.3;
else if (is_opera) is_js = 1.1;
else if ((is_nav4 && (is_minor <4.05)) || is_ie4) is_js 1.2;
else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
else if (is_nav5 && !(is_nav6)) is_js = 1.4;
else if (is_hotjava3up) is_js = 1.4; // new 020128 - abk
else if (is_nav6) is_js = 1.5;



else if (is_nav && (is_major > 5)) is_js = 1.4
else if (is_ie && (is_major > 5)) is_js = 1.3


else is_js = 0.0;
// HACK FOR IE5 MAC js vers 1.4 (if put inside if/else jumps out at 1.3)
if ((agt.indexOf("mac")!=-1) && is_ie5up) is_js = 1.4; // 020128 - abk

// *** PLATFORM ***
var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
// Win32, so you can't distinguish between Win95 and WinNT.
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

// is this a 16 bit compiled version?
var is_win16 = ((agt.indexOf("win16")!=-1) ||
(agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
(agt.indexOf("windows 16-bit")!=-1) );

var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
(agt.indexOf("windows 16-bit")!=-1));

var is_winme = ((agt.indexOf("win 9x 4.90")!=-1)); // new 020128 - abk
var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1)); // new 020128 - abk


var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 ||
((is_major >4) && (navigator.platform "Win32")) ||
(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

var is_os2 = ((agt.indexOf("os/2")!=-1) ||
(navigator.appVersion.indexOf("OS/2")!=-1) ||
(agt.indexOf("ibm-webexplorer")!=-1));

var is_mac = (agt.indexOf("mac")!=-1);
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
(agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
(agt.indexOf("powerpc")!=-1)));

var is_sun = (agt.indexOf("sunos")!=-1);
var is_sun4 = (agt.indexOf("sunos 4")!=-1);
var is_sun5 = (agt.indexOf("sunos 5")!=-1);
var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
var is_irix = (agt.indexOf("irix") !=-1); // SGI
var is_irix5 = (agt.indexOf("irix 5") !=-1);
var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
var is_hpux = (agt.indexOf("hp-ux")!=-1);
var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
var is_aix = (agt.indexOf("aix") !=-1); // IBM
var is_aix1 = (agt.indexOf("aix 1") !=-1);
var is_aix2 = (agt.indexOf("aix 2") !=-1);
var is_aix3 = (agt.indexOf("aix 3") !=-1);
var is_aix4 = (agt.indexOf("aix 4") !=-1);
var is_linux = (agt.indexOf("inux")!=-1);
var is_sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1);
var is_mpras = (agt.indexOf("ncr")!=-1);
var is_reliant = (agt.indexOf("reliantunix")!=-1);
var is_dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
(agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
(agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
var is_sinix = (agt.indexOf("sinix")!=-1);
var is_freebsd = (agt.indexOf("freebsd")!=-1);
var is_bsd = (agt.indexOf("bsd")!=-1);
var is_unix = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
is_sco ||is_unixware || is_mpras || is_reliant ||
is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

var is_vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
// additional checks, abk
var is_anchors = (document.anchors) ? "true":"false";
var is_regexp = (window.RegExp) ? "true":"false";
var is_option = (window.Option) ? "true":"false";
var is_all = (document.all) ? "true":"false";
// cookies - 990624 - abk
document.cookie = "cookies=true";
var is_cookie = (document.cookie) ? "true" : "false";
var is_images = (document.images) ? "true":"false";
var is_layers = (document.layers) ? "true":"false"; // gecko m7 bug?
// new doc obj tests 990624-abk
var is_forms = (document.forms) ? "true" : "false";
var is_links = (document.links) ? "true" : "false";
var is_frames = (window.frames) ? "true" : "false";
var is_screen = (window.screen) ? "true" : "false";

// java
var is_java = (navigator.javaEnabled());

//--> end hide JavaScript
</script>
</head>




Navigator Object Data


<tt><script LANGUAGE ="JavaScript">
<!--

document.write("navigator.appCodeName: " + navigator.appCodeName + "
");
document.write('<code>navigator.appName<\/code>: ' + navigator.appName + "
");
document.write('<code>navigator.appVersion<\/code>: ' + navigator.appVersion + "
");
document.write("navigator.userAgent: " + navigator.userAgent + "
");

document.write("navigator.platform: " + navigator.platform + "
");
document.write("navigator.javaEnabled(): " + is_java + "
");
//-->
</script>

</tt>

Version Number

<tt><script LANGUAGE= "JavaScript">
<!--
document.write("<TT>parseInt(navigator.appVersion) - major:" + is_major + "</TT>
");
document.write("<TT>parseFloat(navigator.appVersion) - minor:" + is_minor + "</TT>
");
//--></script>
</tt>

Browser Version


<tt><script LANGUAGE ="JavaScript">
<!--
document.write("nav:" + is_nav + "
");
document.write("nav2:" + is_nav2 + "
");
document.write("nav3:" + is_nav3 + "
");
document.write("nav4:" + is_nav4 + "
");
document.write("nav4up:" + is_nav4up + "
");
document.write("nav5:" + is_nav5 + "
");
document.write("nav5up:" + is_nav5up + "
");
document.write("nav6:" + is_nav6 + "
");
document.write("nav6up:" + is_nav6up + ""); // 001121 new - abk
// document.write("navonly:" + is_navonly + "
");
// is false in ns6?
document.write("ie:" + is_ie + "
");
document.write("ie3:" + is_ie3 + "
");
document.write("ie4:" + is_ie4 + "
");
document.write("ie4up:" + is_ie4up + "
");
document.write("ie5:" + is_ie5 + "
");
document.write("ie5up:" + is_ie5up + "
");
document.write("ie5_5:" + is_ie5_5 + "
");
document.write("ie5_5up:" + is_ie5_5up + "
");
document.write("ie6:" + is_ie6 + "
");
document.write("ie6up:" + is_ie6up + "");
document.write("aol:" + is_aol + "
");
document.write("aol3:" + is_aol3 + "
");
document.write("aol4:" + is_aol4 + "
");
document.write("aol5:" + is_aol5 + "
");
document.write("aol6:" + is_aol6 + "
");

document.write("" + "opera:" + is_opera + "
");
document.write("opera2:" + is_opera2 + "
");
document.write("opera3:" + is_opera3 + "
");
document.write("opera4:" + is_opera4 + "
");
document.write("opera5:" + is_opera5 + "
");
document.write("opera5up:" + is_opera5up + "
");
document.write("opera6:" + is_opera6 + "
");
document.write("opera6up:" + is_opera6up + "
");

document.write("" + "webtv:" + is_webtv + "
");
document.write("" + "hotjava:" + is_hotjava + "
");
document.write("hotjava3:" + is_hotjava3 + "
");
document.write("hotjava3up:" + is_hotjava3up + "
");
document.write("" + "AOL TV(TVNavigator):" + is_TVNavigator + "
");
//-->
</script>
</tt>

JavaScript Version

<tt>
<script LANGUAGE= "JavaScript">
<!--
document.write("js:" + is_js + "
");
//-->
</script>

<SCRIPT LANGUAGE=JScript>
<!--
// 020131 included is_ie check to filter opera which doesn't recognize
// ScriptEngine() and spawns an error - dragle
if((document.all) && (is_ie)) {
document.write("IE 4/5/6 Script Engines Installed: " + ScriptEngine() + "
");
document.write("Version: " + ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion() + "." + ScriptEngineBuildVersion() + "
");
}
//-->
</SCRIPT>
</tt>


OS


<tt><script LANGUAGE ="JavaScript">
<!--
document.write("win:" + is_win + "
");
// document.write("win16:" + is_win16 + "
");
// document.write("win31:" + is_win31 + "
");
// document.write("win32:" + is_win32 + "
");
// document.write("win95:" + is_win95 + "
");
// document.write("win98:" + is_win98 + "
");
// document.write("winme:" + is_winme + "
");
// document.write("winnt:" + is_winnt + "
");
// document.write("win2k:" + is_win2k + "
");

document.write("os2:" + is_os2 + "
");

document.write("mac:" + is_mac + "
");
// document.write("mac68k:" + is_mac68k + "
");
// document.write("macppc:" + is_macppc + "
");

document.write("unix:" + is_unix + "
");
document.write("sun:" + is_sun + "
");
// document.write("sun4:" + is_sun4 + "
");
// document.write("sun5:" + is_sun5 + "
");
// document.write("suni86:" + is_suni86 + "
");
document.write("irix:" + is_irix + "
");
// document.write("irix5:" + is_irix5 + "
");
// document.write("irix6:" + is_irix6 + "
");
document.write("hpux:" + is_hpux + "
");
// document.write("hpux9:" + is_hpux9 + "
");
// document.write("hpux10:" + is_hpux10 + "
");
document.write("aix:" + is_aix + "
");
// document.write("aix1:" + is_aix1 + "
");
// document.write("aix2:" + is_aix2 + "
");
// document.write("aix3:" + is_aix3 + "
");
// document.write("aix4:" + is_aix4 + "
");
document.write("linux:" + is_linux + "
");
document.write("sco:" + is_sco + "
");
document.write("unixware:" + is_unixware + "
");
document.write("mpras:" + is_mpras + "
");
document.write("reliant:" + is_reliant + "
");
document.write("dec:" + is_dec + "
");
document.write("sinix:" + is_sinix + "
");
document.write("bsd:" + is_bsd + "
");
document.write("freebsd:" + is_freebsd + "
");

document.write("vms:" + is_vms + "
");
//-->
</script>
</tt>


Object Detection Tests


<tt><script LANGUAGE= "JavaScript">
<!--
document.write('document.all: ' + is_all + "
");
document.write('document.anchors: ' + is_anchors + "
");
document.write('document.cookie: ' + is_cookie + "
");
document.write('document.forms: ' + is_forms + "
");
document.write('document.getElementById: ' + is_getElementById + "*
"); // new 001121 abk for ns6+
document.write('document.getElementsByTagName: ' + is_getElementsByTagName + "
");
document.write('document.documentElement: ' + is_documentElement + "
");

document.write('document.images: ' + is_images + "
");
document.write('document.layers: ' + is_layers + " - NS6 gives false here**" + "
");
// ' + is_layers + "
");
document.write('document.links: ' + is_links + "

");
document.write('window.frames: ' + is_frames + "
");
document.write('window.length: ' + window.length +"
");

//-->
</script>
</tt>


Method Detection Tests


<tt><script LANGUAGE ="JavaScript">
<!--
document.write('window.RegExp: ' + is_regexp + "
");
document.write('window.Option: ' + is_option + "
");

//-->
</script>

</tt>


Screen Properties


<tt><script LANGUAGE= "JavaScript">
<!--
document.write('window.screen: ' + is_screen + "
");
if (window.screen) {
document.write('screen.height: ' + screen.height + "
");
document.write('screen.width: ' + screen.width + "
");
document.write('screen.availHeight: ' + screen.availHeight + "
");
document.write('screen.availWidth: ' + screen.availWidth + "
");
document.write('screen.colorDepth: ' + screen.colorDepth + "
");
}
//-->
</script>


<SCRIPT LANGUAGE=JScript>
<!--
if (window.screen) {
document.write("fontSmoothingEnabled: " + screen.fontSmoothingEnabled + "
");
}
//-->
</SCRIPT>
</tt>


Document Properties


<tt><script LANGUAGE ="JavaScript">
<!--
// document.write('document.lastModified: ' + document.lastModified + "
"); // gecko bug?
// document.write('document.referrer: ' + document.referrer + "
");
document.write('document.URL: ' + document.URL + "
");
//-->
</script>

</tt>



</td></tr></table>


</HTML>
cs_Deny
Messages postés
41
Date d'inscription
lundi 21 octobre 2002
Statut
Membre
Dernière intervention
16 février 2009
-
Tu l'a essayé ?
A détecter tout ce qui est implanté sur ton ordinateur, toutes les caractéristiques de ton, ou tes, navigateur(s).
Et donc ceux des autres, par extension, selon.

exemple IE ver 6.0-2800.1006
Object Detection Tests
document.all: true
document.anchors: true
document.cookie: true
document.forms: true
document.getElementById: true*
document.getElementsByTagName: true
document.documentElement: true
document.images: true
document.layers: false - NS6 gives false here**
document.links: true

Screen Properties
window.screen: true
screen.height: 600
screen.width: 800
screen.availHeight: 570
screen.availWidth: 800
screen.colorDepth: 32
fontSmoothingEnabled: true


etc...

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.