Finish implement js field

main
Camille Barneaud 7 years ago
parent 7d268ed8a3
commit 9ba4c7ea85

@ -35,7 +35,25 @@ if ( typeof browser !== 'undefined' && typeof document.body !== 'undefined' ) {
script.setAttribute('id', 'wappalyzerEnvDetection');
script.setAttribute('src', browser.extension.getURL('js/inject.js'));
container.addEventListener('wappalyzerEvent', (event => {
container.addEventListener('wappalyzerEnvEvent', (event => {
browser.runtime.sendMessage({
id: 'JS_ready',
subject: { },
source: 'content.js'
}, response => {
window.postMessage({patterns: response.patterns}, "*");
});
window.addEventListener('message', (event => {
if (event.data.js === undefined)
return;
var js = event.data.js ;
browser.runtime.sendMessage({
id: 'analyze',
subject: { js },
source: 'content.js'
});
}), true);
var env = event.target.childNodes[0].nodeValue;
document.documentElement.removeChild(container);

@ -1,42 +1,33 @@
(function() {
try {
var i, environmentVars = '', e = document.createEvent('Events');
var i, environmentVars = '', eEnv = document.createEvent('Events'), container = document.getElementById('wappalyzerData');
e.initEvent('wappalyzerEvent', true, false);
eEnv.initEvent('wappalyzerEnvEvent', true, false);
for ( i in window ) {
environmentVars += i + ' ';
}
container.appendChild(document.createComment(environmentVars));
container.dispatchEvent(eEnv);
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;
window.addEventListener('message', (event => {
if (event.data.patterns === undefined)
return;
var properties = event.data.patterns;
var js = {};
Object.keys(properties).forEach(app => {
Object.keys(properties[app]).forEach(property => {
Object.keys(properties).forEach(appname => {
Object.keys(properties[appname]).forEach(property => {
var content = false;
if( content = JSdetection(property) ){
if ( js[appname] === undefined ) {
if ( js[appname] === undefined )
js[appname] = {};
}
js[appname][property] = properties[app][property];
js[appname][property] = properties[appname][property];
js[appname][property]["content"] = content;
}
});
});
browser.runtime.sendMessage({
id: 'analyze',
subject: { js },
source: 'inject.js'
});
});
window.postMessage({js: js}, "*");
}), false);
} catch(e) {
// Fail quietly
}
@ -49,4 +40,4 @@ function JSdetection(p){
}, window);
return typeof value === 'string' ? value : !!value;
}
}

@ -18,7 +18,7 @@ class Wappalyzer {
this.apps = {};
this.categories = {};
this.driver = {};
this.parsedJS = {};
this.parsedJS = undefined;
this.detected = {};
this.hostnameCache = {};
@ -85,7 +85,7 @@ class Wappalyzer {
if ( data.js ) {
Object.keys(data.js).forEach(appName => {
this.analyzeJS(this.apps[appname], data.js[appname])
this.analyzeJS(apps[appName], data.js[appName]);
});
}
@ -255,14 +255,13 @@ class Wappalyzer {
* Parse JS patterns
*/
parseJS() {
if ( this.parsedJS == {} ){
if ( this.parsedJS === undefined){
this.parsedJS = {};
Object.keys(this.apps).forEach(appName => {
if (apps[appName].props.js){
parsedJS[appName] = this.parsePatterns(apps[appName].props.js);
}
if (this.apps[appName].js)
this.parsedJS[appName] = this.parsePatterns(this.apps[appName].js);
});
}
return this.parsedJS
}
resolveExcludes(apps) {

Loading…
Cancel
Save