Added tracking function to Chrome driver

main
ElbertF 13 years ago
parent 65c89998fa
commit b07b8b6541

@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
if ( func != 'log' ) w.log('w.driver.' + func);
if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
if ( type == null ) type = 'debug';
if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
w.config.upgraded = false;
}
});
},
@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
var apps = new Array();
var app, type, apps = [];
if ( w.history[hostname] == null ) w.history[hostname] = new Array();
if ( w.detected[url] == null ) w.detected[url] = new Array();
if ( w.history[hostname] == null ) { w.history[hostname] = []; }
if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
for ( var app in w.apps ) {
for ( var type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
for ( app in w.apps ) {
for ( type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
if ( w.apps[app].url.test(url) ) apps.push(app);
if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) apps.push(app);
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<script[^>]+src=("|')([^"']+)\1/ig,
@ -128,18 +137,19 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'meta':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<meta[^>]+>/ig,
match = [],
content,
meta
;
while ( match = regex.exec(data['html']) ) {
for ( meta in w.apps[app][type] ) {
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
var content = match.toString().match(/content=("|')([^"']+)("|')/i);
content = match.toString().match(/content=("|')([^"']+)("|')/i);
if ( content && w.apps[app].meta[meta].test(content[2]) ) {
apps.push(app);
@ -152,9 +162,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'headers':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
for ( var header in w.apps[app].headers ) {
var header;
for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
apps.push(app);
@ -164,9 +176,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'env':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
var i;
for ( var i in data[type] ) {
for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) {
apps.push(app);
@ -180,13 +194,13 @@ var wappalyzer = wappalyzer || (function() {
}
// Implied applications
var i, j, k;
var i, j, k, implied;
for ( i = 0; i < 3; i ++ ) {
for ( j in apps ) {
if ( w.apps[apps[j]] && w.apps[apps[j]].implies ) {
for ( k in w.apps[apps[j]].implies ) {
var implied = w.apps[apps[j]].implies[k];
implied = w.apps[apps[j]].implies[k];
if ( !w.apps[implied] ) {
w.log('Implied application ' + implied + ' does not exist');
@ -205,13 +219,17 @@ var wappalyzer = wappalyzer || (function() {
w.log(apps.length + ' apps detected: ' + apps.join(', '));
// Keep history of detected apps
apps.map(function(app) {
var i, app;
for ( i in apps ) {
app = apps[i];
if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) {
// Per hostname
var index = -1;
w.history[hostname].map(function(data, i) {
if ( data.app == app ) index = i;
if ( data.app === app ) { index = i; }
});
if ( index === -1 ) {
@ -220,12 +238,12 @@ var wappalyzer = wappalyzer || (function() {
w.history[hostname][index].hits ++;
}
if ( Object.keys(w.history).length >= 200 ) driver('track');
if ( Object.keys(w.history).length >= 200 ) { driver('track'); }
}
// Per URL
if ( w.detected[url].indexOf(app) === -1 ) w.detected[url].push(app);
});
if ( w.detected[url].indexOf(app) === -1 ) { w.detected[url].push(app); }
};
apps = null;
data = null;

@ -7,6 +7,7 @@
<script src="js/ga.js"></script>
<script src="js/wappalyzer.js"></script>
<script src="js/apps.js"></script>
<script src="js/defaults.js"></script>
<script src="js/driver.js"></script>
<script src="js/background.js"></script>
</head>

@ -69,7 +69,7 @@ img {
}
#analyze-headers.pending {
background: url('images/pending.gif') center center no-repeat;
background: url('../images/pending.gif') center center no-repeat;
color: #999;
text-indent: -999px;
}

@ -5,12 +5,7 @@
(function() {
if ( wappalyzer == null ) { return; }
var w = wappalyzer;
var
tab,
tabCache = {}
;
var w = wappalyzer, tab, tabCache = {};
w.driver = {
/**
@ -28,6 +23,24 @@
chrome.browserAction.setBadgeBackgroundColor({ color: [255, 102, 0, 255] });
// Version check
try {
var version = chrome.app.getDetails().version;
if ( localStorage['version'] == null ) {
w.config.firstRun = true;
// Set defaults
for ( option in defaults ) {
localStorage[option] = defaults[option];
}
} else if ( version !== localStorage['version'] ) {
w.config.upgraded = true;
}
localStorage['version'] = version;
} catch(e) { }
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if ( typeof request.id != 'undefined' ) {
w.log('request: ' + request.id);
@ -40,7 +53,13 @@
case 'analyze':
tab = sender.tab;
w.analyze(tab.url, tab.url, request.subject);
var hostname, a = document.createElement('a');
a.href = tab.url;
hostname = a.hostname;
w.analyze(hostname, tab.url, request.subject);
for ( subject in request.subject ) {
tabCache[tab.id].analyzed.push(subject);
@ -72,6 +91,12 @@
tabCache[tabId] = null;
});
callback();
},
goToURL: function(args) {
window.open(args.url);
},
/**
@ -93,10 +118,12 @@
if ( count > 0 ) {
// Find the main application to display
var found = false;
var i, appName, found = false;
w.driver.categoryOrder.map(function(match) {
w.detected[tab.url].map(function(appName) {
for ( i in w.detected[tab.url] ) {
appName = w.detected[tab.url][i];
w.apps[appName].cats.map(function(cat) {
if ( cat === match && !found ) {
chrome.browserAction.setIcon({ tabId: tab.id, path: 'images/icons/' + appName + '.png' });
@ -104,13 +131,59 @@
found = true;
}
});
});
}
});
chrome.browserAction.setBadgeText({ tabId: tab.id, text: count });
};
},
/**
* Anonymously track detected applications
*/
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 += ']';
}
// Make POST request
var request = new XMLHttpRequest();
request.open('POST', w.config.websiteURL + '_track.php', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
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));
}
}
},
categoryOrder: [ // Used to pick the main application
1, // CMS
11, // Blog

@ -10,7 +10,7 @@ _gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.src = 'https://ssl.google-analytics.com/u/ga_debug.js';
ga.src = 'https://ssl.google-analytics.com/ga.js';
ga.async = true;
var s = document.getElementsByTagName('script')[0];

@ -1,8 +1,6 @@
$(function() {
var options = {
opts: {
tracking: 1
},
opts: defaults,
init: function() {
options.load();

@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
if ( func != 'log' ) w.log('w.driver.' + func);
if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
if ( type == null ) type = 'debug';
if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
w.config.upgraded = false;
}
});
},
@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
var apps = new Array();
var app, type, apps = [];
if ( w.history[hostname] == null ) w.history[hostname] = new Array();
if ( w.detected[url] == null ) w.detected[url] = new Array();
if ( w.history[hostname] == null ) { w.history[hostname] = []; }
if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
for ( var app in w.apps ) {
for ( var type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
for ( app in w.apps ) {
for ( type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
if ( w.apps[app].url.test(url) ) apps.push(app);
if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) apps.push(app);
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<script[^>]+src=("|')([^"']+)\1/ig,
@ -128,18 +137,19 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'meta':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<meta[^>]+>/ig,
match = [],
content,
meta
;
while ( match = regex.exec(data['html']) ) {
for ( meta in w.apps[app][type] ) {
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
var content = match.toString().match(/content=("|')([^"']+)("|')/i);
content = match.toString().match(/content=("|')([^"']+)("|')/i);
if ( content && w.apps[app].meta[meta].test(content[2]) ) {
apps.push(app);
@ -152,9 +162,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'headers':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
for ( var header in w.apps[app].headers ) {
var header;
for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
apps.push(app);
@ -164,9 +176,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'env':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
var i;
for ( var i in data[type] ) {
for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) {
apps.push(app);
@ -180,13 +194,13 @@ var wappalyzer = wappalyzer || (function() {
}
// Implied applications
var i, j, k;
var i, j, k, implied;
for ( i = 0; i < 3; i ++ ) {
for ( j in apps ) {
if ( w.apps[apps[j]] && w.apps[apps[j]].implies ) {
for ( k in w.apps[apps[j]].implies ) {
var implied = w.apps[apps[j]].implies[k];
implied = w.apps[apps[j]].implies[k];
if ( !w.apps[implied] ) {
w.log('Implied application ' + implied + ' does not exist');
@ -205,13 +219,17 @@ var wappalyzer = wappalyzer || (function() {
w.log(apps.length + ' apps detected: ' + apps.join(', '));
// Keep history of detected apps
apps.map(function(app) {
var i, app;
for ( i in apps ) {
app = apps[i];
if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) {
// Per hostname
var index = -1;
w.history[hostname].map(function(data, i) {
if ( data.app == app ) index = i;
if ( data.app === app ) { index = i; }
});
if ( index === -1 ) {
@ -220,12 +238,12 @@ var wappalyzer = wappalyzer || (function() {
w.history[hostname][index].hits ++;
}
if ( Object.keys(w.history).length >= 200 ) driver('track');
if ( Object.keys(w.history).length >= 200 ) { driver('track'); }
}
// Per URL
if ( w.detected[url].indexOf(app) === -1 ) w.detected[url].push(app);
});
if ( w.detected[url].indexOf(app) === -1 ) { w.detected[url].push(app); }
};
apps = null;
data = null;

@ -1,7 +1,7 @@
{ "name": "Wappalyzer",
"homepage_url": "http://wappalyzer.com",
"description": "Identifies software on the web",
"version": "2.2",
"version": "2.3",
"default_locale": "en",
"manifest_version": 2,
"icons": {

@ -9,6 +9,7 @@
<script src="js/ga.js"></script>
<script src="js/lib/jquery.min.js"></script>
<script src="js/defaults.js"></script>
<script src="js/options.js"></script>
<script src="js/i18n.js"></script>
</head>

@ -199,7 +199,7 @@
});
report += ']';
};
}
// Make POST request
var request = new XMLHttpRequest();
@ -213,16 +213,16 @@
request.onreadystatechange = function(e) {
if ( request.readyState == 4 ) {
if ( request.status == 200 ) {
w.history = new Object();
w.history = [];
w.log('w.driver.track: ' + report);
}
report = '';
if ( request.close ) request.close();
if ( request.close ) { request.close(); }
request = false;
request = null;
}
};

@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
if ( func != 'log' ) w.log('w.driver.' + func);
if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
if ( type == null ) type = 'debug';
if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
w.config.upgraded = false;
}
});
},
@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
var apps = new Array();
var app, type, apps = [];
if ( w.history[hostname] == null ) w.history[hostname] = new Array();
if ( w.detected[url] == null ) w.detected[url] = new Array();
if ( w.history[hostname] == null ) { w.history[hostname] = []; }
if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
for ( var app in w.apps ) {
for ( var type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
for ( app in w.apps ) {
for ( type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
if ( w.apps[app].url.test(url) ) apps.push(app);
if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) apps.push(app);
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<script[^>]+src=("|')([^"']+)\1/ig,
@ -128,18 +137,19 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'meta':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<meta[^>]+>/ig,
match = [],
content,
meta
;
while ( match = regex.exec(data['html']) ) {
for ( meta in w.apps[app][type] ) {
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
var content = match.toString().match(/content=("|')([^"']+)("|')/i);
content = match.toString().match(/content=("|')([^"']+)("|')/i);
if ( content && w.apps[app].meta[meta].test(content[2]) ) {
apps.push(app);
@ -152,9 +162,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'headers':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
for ( var header in w.apps[app].headers ) {
var header;
for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
apps.push(app);
@ -164,9 +176,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'env':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
var i;
for ( var i in data[type] ) {
for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) {
apps.push(app);
@ -180,13 +194,13 @@ var wappalyzer = wappalyzer || (function() {
}
// Implied applications
var i, j, k;
var i, j, k, implied;
for ( i = 0; i < 3; i ++ ) {
for ( j in apps ) {
if ( w.apps[apps[j]] && w.apps[apps[j]].implies ) {
for ( k in w.apps[apps[j]].implies ) {
var implied = w.apps[apps[j]].implies[k];
implied = w.apps[apps[j]].implies[k];
if ( !w.apps[implied] ) {
w.log('Implied application ' + implied + ' does not exist');
@ -205,13 +219,17 @@ var wappalyzer = wappalyzer || (function() {
w.log(apps.length + ' apps detected: ' + apps.join(', '));
// Keep history of detected apps
apps.map(function(app) {
var i, app;
for ( i in apps ) {
app = apps[i];
if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) {
// Per hostname
var index = -1;
w.history[hostname].map(function(data, i) {
if ( data.app == app ) index = i;
if ( data.app === app ) { index = i; }
});
if ( index === -1 ) {
@ -220,12 +238,12 @@ var wappalyzer = wappalyzer || (function() {
w.history[hostname][index].hits ++;
}
if ( Object.keys(w.history).length >= 200 ) driver('track');
if ( Object.keys(w.history).length >= 200 ) { driver('track'); }
}
// Per URL
if ( w.detected[url].indexOf(app) === -1 ) w.detected[url].push(app);
});
if ( w.detected[url].indexOf(app) === -1 ) { w.detected[url].push(app); }
};
apps = null;
data = null;

@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
if ( func != 'log' ) w.log('w.driver.' + func);
if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
if ( type == null ) type = 'debug';
if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
w.config.upgraded = false;
}
});
},
@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
var apps = new Array();
var app, type, apps = [];
if ( w.history[hostname] == null ) w.history[hostname] = new Array();
if ( w.detected[url] == null ) w.detected[url] = new Array();
if ( w.history[hostname] == null ) { w.history[hostname] = []; }
if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
for ( var app in w.apps ) {
for ( var type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
for ( app in w.apps ) {
for ( type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
if ( w.apps[app].url.test(url) ) apps.push(app);
if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) apps.push(app);
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<script[^>]+src=("|')([^"']+)\1/ig,
@ -128,18 +137,19 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'meta':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<meta[^>]+>/ig,
match = [],
content,
meta
;
while ( match = regex.exec(data['html']) ) {
for ( meta in w.apps[app][type] ) {
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
var content = match.toString().match(/content=("|')([^"']+)("|')/i);
content = match.toString().match(/content=("|')([^"']+)("|')/i);
if ( content && w.apps[app].meta[meta].test(content[2]) ) {
apps.push(app);
@ -152,9 +162,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'headers':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
for ( var header in w.apps[app].headers ) {
var header;
for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
apps.push(app);
@ -164,9 +176,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'env':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
var i;
for ( var i in data[type] ) {
for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) {
apps.push(app);
@ -180,13 +194,13 @@ var wappalyzer = wappalyzer || (function() {
}
// Implied applications
var i, j, k;
var i, j, k, implied;
for ( i = 0; i < 3; i ++ ) {
for ( j in apps ) {
if ( w.apps[apps[j]] && w.apps[apps[j]].implies ) {
for ( k in w.apps[apps[j]].implies ) {
var implied = w.apps[apps[j]].implies[k];
implied = w.apps[apps[j]].implies[k];
if ( !w.apps[implied] ) {
w.log('Implied application ' + implied + ' does not exist');
@ -205,13 +219,17 @@ var wappalyzer = wappalyzer || (function() {
w.log(apps.length + ' apps detected: ' + apps.join(', '));
// Keep history of detected apps
apps.map(function(app) {
var i, app;
for ( i in apps ) {
app = apps[i];
if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) {
// Per hostname
var index = -1;
w.history[hostname].map(function(data, i) {
if ( data.app == app ) index = i;
if ( data.app === app ) { index = i; }
});
if ( index === -1 ) {
@ -220,12 +238,12 @@ var wappalyzer = wappalyzer || (function() {
w.history[hostname][index].hits ++;
}
if ( Object.keys(w.history).length >= 200 ) driver('track');
if ( Object.keys(w.history).length >= 200 ) { driver('track'); }
}
// Per URL
if ( w.detected[url].indexOf(app) === -1 ) w.detected[url].push(app);
});
if ( w.detected[url].indexOf(app) === -1 ) { w.detected[url].push(app); }
};
apps = null;
data = null;

@ -19,7 +19,7 @@ var wappalyzer = wappalyzer || (function() {
return;
}
if ( func != 'log' ) w.log('w.driver.' + func);
if ( func !== 'log' ) { w.log('w.driver.' + func); }
return w.driver[func](args);
};
@ -51,7 +51,7 @@ var wappalyzer = wappalyzer || (function() {
*/
log: function(message, type) {
if ( w.config.environment === 'dev' ) {
if ( type == null ) type = 'debug';
if ( type == null ) { type = 'debug'; }
driver('log', { message: '[wappalyzer ' + type + '] ' + message, type: type });
}
@ -78,8 +78,17 @@ var wappalyzer = wappalyzer || (function() {
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) driver('goToURL', { url: w.config.websiteURL + 'installed' });
if ( w.config.upgraded ) driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded' });
w.config.upgraded = false;
}
});
},
@ -89,29 +98,29 @@ var wappalyzer = wappalyzer || (function() {
analyze: function(hostname, url, data) {
w.log('w.analyze');
var apps = new Array();
var app, type, apps = [];
if ( w.history[hostname] == null ) w.history[hostname] = new Array();
if ( w.detected[url] == null ) w.detected[url] = new Array();
if ( w.history[hostname] == null ) { w.history[hostname] = []; }
if ( w.detected[url] == null ) { w.detected[url] = []; }
if ( data ) {
for ( var app in w.apps ) {
for ( var type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) continue; // Skip if the app has already been detected
for ( app in w.apps ) {
for ( type in w.apps[app] ) {
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) { continue; } // Skip if the app has already been detected
switch ( type ) {
case 'url':
if ( w.apps[app].url.test(url) ) apps.push(app);
if ( w.apps[app].url.test(url) ) { apps.push(app); }
break;
case 'html':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
if ( w.apps[app][type].test(data[type]) ) apps.push(app);
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
break;
case 'script':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<script[^>]+src=("|')([^"']+)\1/ig,
@ -128,18 +137,19 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'meta':
if ( data['html'] == null ) break;
if ( data['html'] == null ) { break; }
var
regex = /<meta[^>]+>/ig,
match = [],
content,
meta
;
while ( match = regex.exec(data['html']) ) {
for ( meta in w.apps[app][type] ) {
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
var content = match.toString().match(/content=("|')([^"']+)("|')/i);
content = match.toString().match(/content=("|')([^"']+)("|')/i);
if ( content && w.apps[app].meta[meta].test(content[2]) ) {
apps.push(app);
@ -152,9 +162,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'headers':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
for ( var header in w.apps[app].headers ) {
var header;
for ( header in w.apps[app].headers ) {
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
apps.push(app);
@ -164,9 +176,11 @@ var wappalyzer = wappalyzer || (function() {
break;
case 'env':
if ( data[type] == null ) break;
if ( data[type] == null ) { break; }
var i;
for ( var i in data[type] ) {
for ( i in data[type] ) {
if ( w.apps[app][type].test(data[type][i]) ) {
apps.push(app);
@ -180,13 +194,13 @@ var wappalyzer = wappalyzer || (function() {
}
// Implied applications
var i, j, k;
var i, j, k, implied;
for ( i = 0; i < 3; i ++ ) {
for ( j in apps ) {
if ( w.apps[apps[j]] && w.apps[apps[j]].implies ) {
for ( k in w.apps[apps[j]].implies ) {
var implied = w.apps[apps[j]].implies[k];
implied = w.apps[apps[j]].implies[k];
if ( !w.apps[implied] ) {
w.log('Implied application ' + implied + ' does not exist');
@ -205,13 +219,17 @@ var wappalyzer = wappalyzer || (function() {
w.log(apps.length + ' apps detected: ' + apps.join(', '));
// Keep history of detected apps
apps.map(function(app) {
var i, app;
for ( i in apps ) {
app = apps[i];
if ( /^[a-z0-9._\-]+\.[a-z]+/.test(hostname) && !/(dev\.|\/admin|\.local)/.test(url) ) {
// Per hostname
var index = -1;
w.history[hostname].map(function(data, i) {
if ( data.app == app ) index = i;
if ( data.app === app ) { index = i; }
});
if ( index === -1 ) {
@ -220,12 +238,12 @@ var wappalyzer = wappalyzer || (function() {
w.history[hostname][index].hits ++;
}
if ( Object.keys(w.history).length >= 200 ) driver('track');
if ( Object.keys(w.history).length >= 200 ) { driver('track'); }
}
// Per URL
if ( w.detected[url].indexOf(app) === -1 ) w.detected[url].push(app);
});
if ( w.detected[url].indexOf(app) === -1 ) { w.detected[url].push(app); }
};
apps = null;
data = null;