Avoid use of prototype functions in inject.js

main
Elbert Alias 8 years ago
parent be78de5aca
commit 4bbda8916b

@ -129,7 +129,7 @@ class Driver {
const scripts = this.getScripts(browser);
const js = this.getJs(browser);
this.wappalyzer.analyze(pageUrl.hostname, pageUrl.href, {
this.wappalyzer.analyze(pageUrl, {
headers,
html,
js,

@ -160,7 +160,7 @@ browser.webRequest.onCompleted.addListener(request => {
( chrome || browser ).runtime.onMessage.addListener((message, sender, sendResponse) => {
if ( typeof message.id != 'undefined' ) {
if ( message.id !== 'log' ) {
wappalyzer.log('Message received from ' + message.source + ': ' + message.id, 'driver');
wappalyzer.log('Message received' + ( message.source ? ' from ' + message.source : '' ) + ': ' + message.id, 'driver');
}
var response;

@ -9,35 +9,53 @@
const js = {};
Object.keys(patterns).forEach(appName => {
js[appName] = {};
for ( let appName in patterns ) {
if ( patterns.hasOwnProperty(appName) ) {
js[appName] = {};
Object.keys(patterns[appName]).forEach(chain => {
js[appName][chain] = {};
for ( let chain in patterns[appName] ) {
if ( patterns[appName].hasOwnProperty(chain) ) {
js[appName][chain] = {};
patterns[appName][chain].forEach((pattern, index) => {
const value = detectJs(chain);
for ( let index in patterns[appName][chain] ) {
const value = detectJs(chain);
if ( value ) {
js[appName][chain][index] = value;
if ( value ) {
js[appName][chain][index] = value;
}
}
}
});
});
});
}
}
}
postMessage({ id: 'js', js }, '*');
}), false);
} catch(e) {
// Fail quietly
}
}());
function detectJs(chain) {
const properties = chain.split('.');
function detectJs(chain) {
try {
const properties = chain.split('.');
var value = properties.length ? window : null;
for ( let i = 0; i < properties.length; i ++ ) {
var property = properties[i];
const value = properties.reduce((parent, property) => {
return parent && parent.hasOwnProperty(property) ? parent[property] : null;
}, window);
if ( value.hasOwnProperty(property) ) {
value = value[property];
} else {
value = null;
return typeof value === 'string' ? value : !!value;
}
break;
}
}
return typeof value === 'string' ? value : !!value;
} catch(e) {
// Fail quietly
}
}
}());