Add language detection

main
Elbert Alias 7 years ago
parent 62de97a496
commit 0f9cc90553

@ -31,6 +31,7 @@ class Driver {
this.origPageUrl = url.parse(pageUrl); this.origPageUrl = url.parse(pageUrl);
this.analyzedPageUrls = []; this.analyzedPageUrls = [];
this.apps = []; this.apps = [];
this.meta = {};
this.wappalyzer = new Wappalyzer(); this.wappalyzer = new Wappalyzer();
@ -38,7 +39,7 @@ class Driver {
this.wappalyzer.categories = json.categories; this.wappalyzer.categories = json.categories;
this.wappalyzer.driver.log = (message, source, type) => this.log(message, source, type); this.wappalyzer.driver.log = (message, source, type) => this.log(message, source, type);
this.wappalyzer.driver.displayApps = detected => this.displayApps(detected); this.wappalyzer.driver.displayApps = (detected, meta, context) => this.displayApps(detected, meta, context);
} }
analyze() { analyze() {
@ -54,9 +55,11 @@ class Driver {
this.options.debug && console.log('[wappalyzer ' + type + ']', '[' + source + ']', message); this.options.debug && console.log('[wappalyzer ' + type + ']', '[' + source + ']', message);
} }
displayApps(detected) { displayApps(detected, meta) {
this.timer('displayApps'); this.timer('displayApps');
this.meta = meta;
Object.keys(detected).forEach(appName => { Object.keys(detected).forEach(appName => {
const app = detected[appName]; const app = detected[appName];
@ -179,7 +182,10 @@ class Driver {
.then(() => { .then(() => {
this.timer('done'); this.timer('done');
resolve(this.apps) resolve({
applications: this.apps,
meta: this.meta
});
}); });
}); });
} }

@ -211,7 +211,7 @@ wappalyzer.driver.log = (message, source, type) => {
/** /**
* Display apps * Display apps
*/ */
wappalyzer.driver.displayApps = (detected, context) => { wappalyzer.driver.displayApps = (detected, meta, context) => {
var tab = context.tab; var tab = context.tab;
tabCache[tab.id] = tabCache[tab.id] || { detected: [] }; tabCache[tab.id] = tabCache[tab.id] || { detected: [] };

@ -51,6 +51,11 @@ class Wappalyzer {
this.detected[url] = {}; this.detected[url] = {};
} }
// Additional information
const matches = data.html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i);
const language = matches && matches.length ? matches[1] : null;
Object.keys(this.apps).forEach(appName => { Object.keys(this.apps).forEach(appName => {
apps[appName] = this.detected[url] && this.detected[url][appName] ? this.detected[url][appName] : new Application(appName, this.apps[appName]); apps[appName] = this.detected[url] && this.detected[url][appName] ? this.detected[url][appName] : new Application(appName, this.apps[appName]);
@ -94,13 +99,13 @@ class Wappalyzer {
this.resolveImplies(apps, url); this.resolveImplies(apps, url);
this.cacheDetectedApps(apps, url); this.cacheDetectedApps(apps, url);
this.trackDetectedApps(apps, url, hostname, data.html); this.trackDetectedApps(apps, url, hostname, language);
if ( Object.keys(apps).length ) { if ( Object.keys(apps).length ) {
this.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core'); this.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core');
} }
this.driver.displayApps(this.detected[url], context); this.driver.displayApps(this.detected[url], { language }, context);
} }
/** /**
@ -326,7 +331,7 @@ class Wappalyzer {
/** /**
* Track detected applications * Track detected applications
*/ */
trackDetectedApps(apps, url, hostname, html) { trackDetectedApps(apps, url, hostname, language) {
if ( !( this.driver.ping instanceof Function ) ) { if ( !( this.driver.ping instanceof Function ) ) {
return; return;
} }
@ -362,13 +367,8 @@ class Wappalyzer {
} }
}); });
// Additional information
if ( hostname in this.hostnameCache ) { if ( hostname in this.hostnameCache ) {
var match = html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i); this.hostnameCache[hostname].meta['language'] = language;
if ( match && match.length ) {
this.hostnameCache[hostname].meta['language'] = match[1];
}
} }
this.ping(); this.ping();

Loading…
Cancel
Save