From 208cf8374e858cef5cc6ca2a304145dcf4e37fdd Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Mon, 2 Jul 2007 16:19:16 +0200 Subject: [PATCH] deal with Firefox spoofing and detect Minimo, Minefield and Netscape9 --- include/classes/useragent.php-class | 49 +++++++++++++++++++---------- testbed/ua_list_raw.txt | 13 ++++++-- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index 9a28094..e71505a 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -164,6 +164,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Navigator/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'Netscape'; + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Chimera'; $this->version = $regs[1]; @@ -189,11 +194,6 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } - elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { - $this->brand = 'Firefox'; - $this->version = $regs[1]; - $this->bot = false; - } elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'SeaMonkey'; $this->version = $regs[1]; @@ -209,6 +209,16 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Minefield'; + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|Minimo/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Minimo'; + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Galeon'; $this->version = $regs[1]; @@ -229,18 +239,6 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } - elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && - strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { - $this->brand = 'Mozilla'; - $this->version = $regs[1]; - $this->bot = false; - } - elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) && - strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { - $this->brand = 'Mozilla'; - $this->version = 'M'.$regs[1]; - $this->bot = false; - } elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) { $this->brand = 'Opera Mini'; $this->version = $regs[1]; @@ -286,6 +284,23 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'Firefox'; + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && + strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { + $this->brand = 'Mozilla'; + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) && + strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { + $this->brand = 'Mozilla'; + $this->version = 'M'.$regs[1]; + $this->bot = false; + } elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Microsoft FrontPage'; $this->version = $regs[1]; diff --git a/testbed/ua_list_raw.txt b/testbed/ua_list_raw.txt index 9952e6d..92cc522 100755 --- a/testbed/ua_list_raw.txt +++ b/testbed/ua_list_raw.txt @@ -15,13 +15,11 @@ Mozilla/5.0 (X11; U; HP-UX 9000/785; en-US; rv:1.4) Gecko/20030730 Mozilla/5.0 (X11; Slackware; Linux i686; en-US; rv:1.7) Gecko/20040618 Mozilla/5.0 (X11; U; Linux i686; rv:1.7.7) Gecko/20050414 Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6; f33eed1469017fe8b64dc7f3261eb135;) Gecko/20040113 -Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7.5) Gecko/20050101 Firefox/1.0 -Mozilla/5.0 (Gameboy Color; U; Gameboy OS 2005; de-DE) Gecko/20041107 Firefox/1.0 -Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040618 MultiZilla/1.6.2.1d Mozilla/5.0 (Linux; U; de, DE, de_DE@euro; m18) Gecko/20001010 Mozilla/5.0 (Windows; U; Win 9x 4.90; de-DE; m18) Gecko/20010131 Netscape6/6.01 Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.0.1) Gecko/20020823 Netscape/7.0 +Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.8.1.5pre) Gecko/20070604 Firefox/2.0.0.4 Navigator/9.0b1 Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1 @@ -29,12 +27,18 @@ Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/ Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040216 Firefox/0.8.0+ Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.7b) Gecko/20040228 Firefox/0.8.0+ (Mozilla/4.7 [en] (Win95; I)) Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 +Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7.5) Gecko/20050101 Firefox/1.0 +Mozilla/5.0 (Gameboy Color; U; Gameboy OS 2005; de-DE) Gecko/20041107 Firefox/1.0 +Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0 Mozilla/5.0 (X11; Linux i686; rv:1.7.5) Gecko/20041108 Firefox/1.0 Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; rv:1.7.5) Gecko/20041107 Firefox/1.0 Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.5) Gecko/20041217 Firefox/1.0.4 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a6pre) Gecko/20070702 Minefield/3.0a6pre Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a +Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a6pre) Gecko/20070628 Firefox/2.0.0.4 SeaMonkey/2.0a1pre PrivatelyFakedUA/0.0 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20021109 Chimera/0.6+ Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7b) Gecko/20040302 Camino/0.7+ +Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.5) Gecko/20070614 Camino/1.6 (like Firefox/2.0.0.4) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.1 Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.7.13) Gecko/20050610 K-Meleon/0.9 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20020730 AOL/7.0 @@ -42,7 +46,9 @@ Mozilla/5.0 (Windows; U; Windows CE 4.21; rv:1.8b4) Gecko/20050720 Minimo/0.007 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20061031 Firefox/1.5.0.7 Flock/0.7.7 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061024 Iceweasel/2.0 (Debian-2.0+dfsg-1) Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031019 Epiphany/1.0.6 +Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.4 Epiphany/1.6.3 Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Epiphany/2.14 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20060410 Firefox/1.0.8 Galeon/1.3.21 Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040402 Galeon/1.3.14 Mozilla/5.0 (X11; U; Linux i686) Gecko/20040319 Galeon/1.3.7 Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20021204 @@ -108,6 +114,7 @@ Mozilla/4.0 (compatible; MSIE 6.0; Mac_PowerPC Mac OS X; en) Opera 8.0 Opera/8.00 (Windows NT 5.1; U; en) Opera/8.01 (X11; Linux i686; U; de) Mozilla/5.0 (X11; Linux i686; U; en) Opera 8.01 +Mozilla/5.0 (Windows NT 5.2; U; cs; rv:1.8.0) Gecko/20060728 Firefox/1.5.0 Opera 9.20 Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 6.0 [de] Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 6600;423) Opera 6.10 [de] Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; Nokia 6630/4.03.38; 6937) Opera 8.50 [es] -- 2.43.0