From 4eb5af3b0d0643fa9ce521d7b890413fe92ff5c7 Mon Sep 17 00:00:00 2001 From: ElbertF Date: Sun, 16 Sep 2012 13:12:18 +1000 Subject: [PATCH] Updated tracker --- drivers/bookmarklet/js/wappalyzer.js | 27 +++---- drivers/chrome/js/driver.js | 49 ++++-------- drivers/chrome/js/wappalyzer.js | 27 +++---- drivers/chrome/manifest.json | 2 +- drivers/firefox/content/js/driver.js | 72 +++++++----------- drivers/firefox/content/js/wappalyzer.js | 27 +++---- drivers/firefox/install.rdf | 4 +- drivers/html/js/wappalyzer.js | 27 +++---- .../{LightMon.png => LightMon Engine.png} | Bin share/js/wappalyzer.js | 27 +++---- 10 files changed, 113 insertions(+), 149 deletions(-) rename share/images/icons/{LightMon.png => LightMon Engine.png} (100%) diff --git a/drivers/bookmarklet/js/wappalyzer.js b/drivers/bookmarklet/js/wappalyzer.js index 01a99bfa3..f2b95df7b 100644 --- a/drivers/bookmarklet/js/wappalyzer.js +++ b/drivers/bookmarklet/js/wappalyzer.js @@ -29,7 +29,7 @@ var wappalyzer = wappalyzer || (function() { */ var w = { // Cache detected applications per URL - history: [], + ping: {}, detected: [], config: { @@ -99,8 +99,7 @@ var wappalyzer = wappalyzer || (function() { var i, app, type, regex, match, content, meta, header, apps = []; - if ( w.history[hostname] == null ) { w.history[hostname] = []; } - if ( w.detected[url] == null ) { w.detected[url] = []; } + if ( w.detected[url] == null ) { w.detected[url] = []; } if ( data ) { for ( app in w.apps ) { @@ -211,21 +210,23 @@ var wappalyzer = wappalyzer || (function() { for ( i in apps ) { app = apps[i]; + // Per hostname if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) { - // Per hostname - var index = -1; + if ( typeof w.ping.hostnames === 'undefined' ) { + w.ping.hostnames = {}; + } - w.history[hostname].map(function(data, i) { - if ( data.app === app ) { index = i; } - }); + if ( typeof w.ping.hostnames[hostname] === 'undefined' ) { + w.ping.hostnames[hostname] = { applications: {} }; + } - if ( index === -1 ) { - w.history[hostname].push({ app: app, hits: 1 }); - } else { - w.history[hostname][index].hits ++; + if ( typeof w.ping.hostnames[hostname].applications[app] === 'undefined' ) { + w.ping.hostnames[hostname].applications[app] = 1; } - if ( Object.keys(w.history).length >= 200 ) { driver('track'); } + w.ping.hostnames[hostname].applications[app] ++; + + if ( Object.keys(w.ping.hostnames).length >= 200 ) { driver('ping'); } } // Per URL diff --git a/drivers/chrome/js/driver.js b/drivers/chrome/js/driver.js index dde0bda98..7b211892c 100644 --- a/drivers/chrome/js/driver.js +++ b/drivers/chrome/js/driver.js @@ -138,49 +138,28 @@ }; }, + /** - * Anonymously track detected applications + * Anonymously track detected applications for research purposes */ - track: function() { - if ( localStorage['tracking'] ) { - var i, data, report = ''; - - if ( w.history ) { - for ( hostname in w.history ) { - report += '[' + hostname; - - w.history[hostname].map(function(data) { - report += '|' + data.app + ':' + data.hits; - }); - - report += ']'; - } + ping: function() { + if ( Object.keys(w.ping.hostnames).length && localStorage['tracking'] ) { + // Make POST request + var request = new XMLHttpRequest(); - // Make POST request - var request = new XMLHttpRequest(); + request.open('POST', w.config.websiteURL + 'ping/', true); - request.open('POST', w.config.websiteURL + '_track.php', true); + request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + request.onreadystatechange = function(e) { + if ( request.readyState == 4 ) { w.log('w.driver.ping: status ' + request.status); } + }; - request.onreadystatechange = function(e) { - if ( request.readyState == 4 ) { - if ( request.status == 200 ) { - w.history = []; + request.send('json=' + encodeURIComponent(JSON.stringify(w.ping))); - w.log('w.driver.track: ' + report); - } - - report = ''; - - if ( request.close ) { request.close(); } + w.log('w.driver.ping: ' + JSON.stringify(w.ping)); - request = null; - } - }; - - request.send('d=' + encodeURIComponent(report)); - } + w.ping = {}; } }, diff --git a/drivers/chrome/js/wappalyzer.js b/drivers/chrome/js/wappalyzer.js index 01a99bfa3..f2b95df7b 100644 --- a/drivers/chrome/js/wappalyzer.js +++ b/drivers/chrome/js/wappalyzer.js @@ -29,7 +29,7 @@ var wappalyzer = wappalyzer || (function() { */ var w = { // Cache detected applications per URL - history: [], + ping: {}, detected: [], config: { @@ -99,8 +99,7 @@ var wappalyzer = wappalyzer || (function() { var i, app, type, regex, match, content, meta, header, apps = []; - if ( w.history[hostname] == null ) { w.history[hostname] = []; } - if ( w.detected[url] == null ) { w.detected[url] = []; } + if ( w.detected[url] == null ) { w.detected[url] = []; } if ( data ) { for ( app in w.apps ) { @@ -211,21 +210,23 @@ var wappalyzer = wappalyzer || (function() { for ( i in apps ) { app = apps[i]; + // Per hostname if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) { - // Per hostname - var index = -1; + if ( typeof w.ping.hostnames === 'undefined' ) { + w.ping.hostnames = {}; + } - w.history[hostname].map(function(data, i) { - if ( data.app === app ) { index = i; } - }); + if ( typeof w.ping.hostnames[hostname] === 'undefined' ) { + w.ping.hostnames[hostname] = { applications: {} }; + } - if ( index === -1 ) { - w.history[hostname].push({ app: app, hits: 1 }); - } else { - w.history[hostname][index].hits ++; + if ( typeof w.ping.hostnames[hostname].applications[app] === 'undefined' ) { + w.ping.hostnames[hostname].applications[app] = 1; } - if ( Object.keys(w.history).length >= 200 ) { driver('track'); } + w.ping.hostnames[hostname].applications[app] ++; + + if ( Object.keys(w.ping.hostnames).length >= 200 ) { driver('ping'); } } // Per URL diff --git a/drivers/chrome/manifest.json b/drivers/chrome/manifest.json index fcc911e75..b8ebd1f09 100644 --- a/drivers/chrome/manifest.json +++ b/drivers/chrome/manifest.json @@ -1,7 +1,7 @@ { "name": "Wappalyzer", "homepage_url": "http://wappalyzer.com", "description": "Identifies software on the web", - "version": "2.4", + "version": "2.5", "default_locale": "en", "manifest_version": 2, "icons": { diff --git a/drivers/firefox/content/js/driver.js b/drivers/firefox/content/js/driver.js index bbc9897de..5cb6dee74 100644 --- a/drivers/firefox/content/js/driver.js +++ b/drivers/firefox/content/js/driver.js @@ -71,14 +71,18 @@ // Get response headers onStateChange: function(progress, request, flags, status) { - if ( request && progress.currentURI && request.nsIHttpChannel && request.name == progress.currentURI.spec && request.contentType == 'text/html' && flags & Ci.nsIWebProgressListener.STATE_STOP ) { - var headers = new Object(); - - request.nsIHttpChannel.visitResponseHeaders(function(header, value) { - headers[header] = value; - }); - - w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers }); + if ( request != null && flags & Ci.nsIWebProgressListener.STATE_STOP ) { + if ( request.nsIHttpChannel && request.contentType == 'text/html' ) { + if ( progress.currentURI && request.name == progress.currentURI.spec ) { + var headers = new Object(); + + request.nsIHttpChannel.visitResponseHeaders(function(header, value) { + headers[header] = value; + }); + + w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers }); + } + } } } }); @@ -187,52 +191,28 @@ }, /** - * Anonymously track detected applications + * Anonymously track detected applications for research purposes */ - track: function() { - if ( prefs.getBoolPref('tracking') ) { - var report = ''; - - if ( w.history ) { - for ( hostname in w.history ) { - report += '[' + hostname; + ping: function() { + if ( Object.keys(w.ping.hostnames).length && prefs.getBoolPref('tracking') ) { + // Make POST request + var request = new XMLHttpRequest(); - w.history[hostname].map(function(data) { - report += '|' + data.app + ':' + data.hits; - }); + request.open('POST', w.config.websiteURL + 'ping/', true); - report += ']'; - } - - // Make POST request - var request = new XMLHttpRequest(); + request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - request.open('POST', w.config.websiteURL + '_track.php', true); + request.onreadystatechange = function(e) { + if ( request.readyState == 4 ) { w.log('w.driver.ping: status ' + request.status); } + }; - request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE; + request.send('json=' + encodeURIComponent(JSON.stringify(w.ping))); - request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + w.log('w.driver.ping: ' + JSON.stringify(w.ping)); - request.onreadystatechange = function(e) { - if ( request.readyState == 4 ) { - if ( request.status == 200 ) { - w.history = []; - - w.log('w.driver.track: ' + report); - } - - report = ''; - - if ( request.close ) { request.close(); } - - request = null; - } - }; - - request.send('d=' + encodeURIComponent(report)); - } + w.ping = {}; } - }, + } }; /** diff --git a/drivers/firefox/content/js/wappalyzer.js b/drivers/firefox/content/js/wappalyzer.js index 01a99bfa3..f2b95df7b 100644 --- a/drivers/firefox/content/js/wappalyzer.js +++ b/drivers/firefox/content/js/wappalyzer.js @@ -29,7 +29,7 @@ var wappalyzer = wappalyzer || (function() { */ var w = { // Cache detected applications per URL - history: [], + ping: {}, detected: [], config: { @@ -99,8 +99,7 @@ var wappalyzer = wappalyzer || (function() { var i, app, type, regex, match, content, meta, header, apps = []; - if ( w.history[hostname] == null ) { w.history[hostname] = []; } - if ( w.detected[url] == null ) { w.detected[url] = []; } + if ( w.detected[url] == null ) { w.detected[url] = []; } if ( data ) { for ( app in w.apps ) { @@ -211,21 +210,23 @@ var wappalyzer = wappalyzer || (function() { for ( i in apps ) { app = apps[i]; + // Per hostname if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) { - // Per hostname - var index = -1; + if ( typeof w.ping.hostnames === 'undefined' ) { + w.ping.hostnames = {}; + } - w.history[hostname].map(function(data, i) { - if ( data.app === app ) { index = i; } - }); + if ( typeof w.ping.hostnames[hostname] === 'undefined' ) { + w.ping.hostnames[hostname] = { applications: {} }; + } - if ( index === -1 ) { - w.history[hostname].push({ app: app, hits: 1 }); - } else { - w.history[hostname][index].hits ++; + if ( typeof w.ping.hostnames[hostname].applications[app] === 'undefined' ) { + w.ping.hostnames[hostname].applications[app] = 1; } - if ( Object.keys(w.history).length >= 200 ) { driver('track'); } + w.ping.hostnames[hostname].applications[app] ++; + + if ( Object.keys(w.ping.hostnames).length >= 200 ) { driver('ping'); } } // Per URL diff --git a/drivers/firefox/install.rdf b/drivers/firefox/install.rdf index ad20007e6..37a995370 100644 --- a/drivers/firefox/install.rdf +++ b/drivers/firefox/install.rdf @@ -3,7 +3,7 @@ wappalyzer@crunchlabz.com - 2.2.3 + 2.3.0 2 true @@ -12,7 +12,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0 - 14.* + 17.* diff --git a/drivers/html/js/wappalyzer.js b/drivers/html/js/wappalyzer.js index 01a99bfa3..f2b95df7b 100644 --- a/drivers/html/js/wappalyzer.js +++ b/drivers/html/js/wappalyzer.js @@ -29,7 +29,7 @@ var wappalyzer = wappalyzer || (function() { */ var w = { // Cache detected applications per URL - history: [], + ping: {}, detected: [], config: { @@ -99,8 +99,7 @@ var wappalyzer = wappalyzer || (function() { var i, app, type, regex, match, content, meta, header, apps = []; - if ( w.history[hostname] == null ) { w.history[hostname] = []; } - if ( w.detected[url] == null ) { w.detected[url] = []; } + if ( w.detected[url] == null ) { w.detected[url] = []; } if ( data ) { for ( app in w.apps ) { @@ -211,21 +210,23 @@ var wappalyzer = wappalyzer || (function() { for ( i in apps ) { app = apps[i]; + // Per hostname if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) { - // Per hostname - var index = -1; + if ( typeof w.ping.hostnames === 'undefined' ) { + w.ping.hostnames = {}; + } - w.history[hostname].map(function(data, i) { - if ( data.app === app ) { index = i; } - }); + if ( typeof w.ping.hostnames[hostname] === 'undefined' ) { + w.ping.hostnames[hostname] = { applications: {} }; + } - if ( index === -1 ) { - w.history[hostname].push({ app: app, hits: 1 }); - } else { - w.history[hostname][index].hits ++; + if ( typeof w.ping.hostnames[hostname].applications[app] === 'undefined' ) { + w.ping.hostnames[hostname].applications[app] = 1; } - if ( Object.keys(w.history).length >= 200 ) { driver('track'); } + w.ping.hostnames[hostname].applications[app] ++; + + if ( Object.keys(w.ping.hostnames).length >= 200 ) { driver('ping'); } } // Per URL diff --git a/share/images/icons/LightMon.png b/share/images/icons/LightMon Engine.png similarity index 100% rename from share/images/icons/LightMon.png rename to share/images/icons/LightMon Engine.png diff --git a/share/js/wappalyzer.js b/share/js/wappalyzer.js index 01a99bfa3..f2b95df7b 100644 --- a/share/js/wappalyzer.js +++ b/share/js/wappalyzer.js @@ -29,7 +29,7 @@ var wappalyzer = wappalyzer || (function() { */ var w = { // Cache detected applications per URL - history: [], + ping: {}, detected: [], config: { @@ -99,8 +99,7 @@ var wappalyzer = wappalyzer || (function() { var i, app, type, regex, match, content, meta, header, apps = []; - if ( w.history[hostname] == null ) { w.history[hostname] = []; } - if ( w.detected[url] == null ) { w.detected[url] = []; } + if ( w.detected[url] == null ) { w.detected[url] = []; } if ( data ) { for ( app in w.apps ) { @@ -211,21 +210,23 @@ var wappalyzer = wappalyzer || (function() { for ( i in apps ) { app = apps[i]; + // Per hostname if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) { - // Per hostname - var index = -1; + if ( typeof w.ping.hostnames === 'undefined' ) { + w.ping.hostnames = {}; + } - w.history[hostname].map(function(data, i) { - if ( data.app === app ) { index = i; } - }); + if ( typeof w.ping.hostnames[hostname] === 'undefined' ) { + w.ping.hostnames[hostname] = { applications: {} }; + } - if ( index === -1 ) { - w.history[hostname].push({ app: app, hits: 1 }); - } else { - w.history[hostname][index].hits ++; + if ( typeof w.ping.hostnames[hostname].applications[app] === 'undefined' ) { + w.ping.hostnames[hostname].applications[app] = 1; } - if ( Object.keys(w.history).length >= 200 ) { driver('track'); } + w.ping.hostnames[hostname].applications[app] ++; + + if ( Object.keys(w.ping.hostnames).length >= 200 ) { driver('ping'); } } // Per URL