|
|
|
@ -92,60 +92,107 @@ var wappalyzer = wappalyzer || (function() {
|
|
|
|
|
analyze: function(hostname, url, data) {
|
|
|
|
|
w.log('w.analyze');
|
|
|
|
|
|
|
|
|
|
data.url = url;
|
|
|
|
|
|
|
|
|
|
if ( w.apps == null || w.categories == null ) {
|
|
|
|
|
w.log('apps.json not loaded');
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var i, app, type, regex, match, content, meta, header, apps = [];
|
|
|
|
|
if ( w.detected[url] == null ) {
|
|
|
|
|
w.detected[url] = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( w.detected[url] == null ) { w.detected[url] = []; }
|
|
|
|
|
var
|
|
|
|
|
i, app, type, regex, match, content, meta, header,
|
|
|
|
|
profiler = {
|
|
|
|
|
regexCount: 0,
|
|
|
|
|
startTime: ( new Date ).getTime()
|
|
|
|
|
},
|
|
|
|
|
apps = []
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
if ( data ) {
|
|
|
|
|
for ( app in w.apps ) {
|
|
|
|
|
// Skip if the app has already been detected
|
|
|
|
|
if ( w.detected[url].indexOf(app) !== -1 || apps.indexOf(app) !== -1 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
next:
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
if ( data[type] == null ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch ( type ) {
|
|
|
|
|
case 'url':
|
|
|
|
|
if ( w.apps[app].url.test(url) ) { apps.push(app); }
|
|
|
|
|
regex = new RegExp(w.apps[app][type], 'i');
|
|
|
|
|
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( regex.test(url) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'html':
|
|
|
|
|
if ( data[type] == null ) { break; }
|
|
|
|
|
regex = new RegExp(w.apps[app][type], 'i');
|
|
|
|
|
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( regex.test(data[type]) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
if ( w.apps[app][type].test(data[type]) ) { apps.push(app); }
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'script':
|
|
|
|
|
if ( data['html'] == null ) { break; }
|
|
|
|
|
if ( data['html'] == null ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
regex = new RegExp(w.apps[app][type], 'i');
|
|
|
|
|
|
|
|
|
|
regex = /<script[^>]+src=("|')([^"']+)\1/ig;
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
while ( match = regex.exec(data['html']) ) {
|
|
|
|
|
if ( w.apps[app][type].test(match[2]) ) {
|
|
|
|
|
while ( match = new RegExp('<script[^>]+src=("|\')([^"\']+)\1', 'ig').exec(data['html']) ) {
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( regex.test(match[2]) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'meta':
|
|
|
|
|
if ( data['html'] == null ) { break; }
|
|
|
|
|
if ( data['html'] == null ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
regex = /<meta[^>]+>/ig;
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
while ( match = regex.exec(data['html']) ) {
|
|
|
|
|
while ( match = new RegExp('<meta[^>]+>', 'ig').exec(data['html']) ) {
|
|
|
|
|
for ( meta in w.apps[app][type] ) {
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
|
|
|
|
|
content = match.toString().match(/content=("|')([^"']+)("|')/i);
|
|
|
|
|
|
|
|
|
|
if ( content && content.length == 4 && w.apps[app].meta[meta].test(content[2]) ) {
|
|
|
|
|
regex = new RegExp(w.apps[app].meta[meta], 'i');
|
|
|
|
|
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( content && content.length === 4 && regex.test(content[2]) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -153,25 +200,37 @@ var wappalyzer = wappalyzer || (function() {
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'headers':
|
|
|
|
|
if ( data[type] == null ) { break; }
|
|
|
|
|
if ( data[type] == null ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( header in w.apps[app].headers ) {
|
|
|
|
|
if ( data[type][header] != null && w.apps[app][type][header].test(data[type][header]) ) {
|
|
|
|
|
regex = new RegExp(w.apps[app][type][header], 'i');
|
|
|
|
|
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( data[type][header] != null && regex.test(data[type][header]) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'env':
|
|
|
|
|
if ( data[type] == null ) { break; }
|
|
|
|
|
if ( data[type] == null ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
regex = RegExp(w.apps[app][type], 'i');
|
|
|
|
|
|
|
|
|
|
for ( i in data[type] ) {
|
|
|
|
|
if ( w.apps[app][type].test(data[type][i]) ) {
|
|
|
|
|
profiler.regexCount ++;
|
|
|
|
|
|
|
|
|
|
if ( regex.test(data[type][i]) ) {
|
|
|
|
|
apps.push(app);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -180,6 +239,8 @@ var wappalyzer = wappalyzer || (function() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
w.log('Tested ' + profiler.regexCount + ' regular expressions in ' + ( ( ( new Date ).getTime() - profiler.startTime ) / 1000 ) + 's');
|
|
|
|
|
|
|
|
|
|
// Implied applications
|
|
|
|
|
var i, j, k, implied;
|
|
|
|
|
|
|
|
|
@ -247,7 +308,6 @@ var wappalyzer = wappalyzer || (function() {
|
|
|
|
|
|
|
|
|
|
apps = null;
|
|
|
|
|
data = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
driver('displayApps');
|
|
|
|
|
}
|
|
|
|
|