Add JS field in Wappalyzer.js & for WebExtension driver

main
Camille Barneaud 7 years ago
parent 5dff4f69e5
commit c6b6df773d

@ -191,6 +191,12 @@ browser.webRequest.onCompleted.addListener(request => {
categories: wappalyzer.categories
};
break;
case 'JS_ready':
response = {
patterns: wappalyzer.parseJS()
};
break;
default:
}

@ -10,7 +10,42 @@
document.getElementById('wappalyzerData').appendChild(document.createComment(environmentVars));
document.getElementById('wappalyzerData').dispatchEvent(e);
// Handle property match
browser.runtime.sendMessage({
id: 'JS_ready',
subject: { },
source: 'inject.js'
}, response => {
var properties = response.patterns;
var js = {};
Object.keys(properties).forEach(app => {
Object.keys(properties[app]).forEach(property => {
if(var content = JSdetection(property)){
if ( js[appname] === undefined ) {
js[appname] = {};
}
js[appname][property] = properties[app][property];
js[appname][property]["content"] = content;
}
});
});
browser.runtime.sendMessage({
id: 'analyze',
subject: { js },
source: 'inject.js'
});
});
} catch(e) {
// Fail quietly
}
}
}());
function JSdetection(p){
const objects = p.split('.');
const value = objects.reduce((parent, property) => {
return parent && parent.hasOwnProperty(property) ? parent[property] : null;
}, window);
return typeof value === 'string' ? value : !!value;
}

@ -18,6 +18,7 @@ class Wappalyzer {
this.apps = {};
this.categories = {};
this.driver = {};
this.parsedJS = {};
this.detected = {};
this.hostnameCache = {};
@ -82,6 +83,12 @@ class Wappalyzer {
}
})
if ( data.js ) {
Object.keys(data.js).forEach(appName => {
this.analyzeJS(this.apps[appname], data.js[appname])
});
}
Object.keys(apps).forEach(appName => {
var app = apps[appName];
@ -244,6 +251,20 @@ class Wappalyzer {
return parsed;
}
/**
* Parse JS patterns
*/
parseJS() {
if ( this.parsedJS == {} ){
Object.keys(this.apps).forEach(appName => {
if (apps[appName].props.js){
parsedJS[appName] = this.parsePatterns(apps[appName].props.js);
}
});
}
return this.parsedJS
}
resolveExcludes(apps) {
var excludes = [];
@ -487,6 +508,21 @@ class Wappalyzer {
}
}
/**
* Analyze JS variables
*/
analyzeJS(app, js) {
Object.keys(js).forEach(property => {
var content = js[property]["content"];
delete js[property]["content"];
js[property].forEach(pattern => {
if ( pattern.regex.test(content) ) {
this.addDetected(app, pattern, 'js', content, property);
}
});
});
}
/**
* Analyze robots.txt
*/

Loading…
Cancel
Save