|
|
|
@ -1,76 +1,58 @@
|
|
|
|
|
/** global: browser */
|
|
|
|
|
|
|
|
|
|
if ( typeof browser !== 'undefined' && typeof document.body !== 'undefined' ) {
|
|
|
|
|
try {
|
|
|
|
|
var html = document.documentElement.outerHTML;
|
|
|
|
|
|
|
|
|
|
if ( html.length > 50000 ) {
|
|
|
|
|
html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var scripts = Array.prototype.slice
|
|
|
|
|
const scripts = Array.prototype.slice
|
|
|
|
|
.apply(document.scripts)
|
|
|
|
|
.filter(s => s.src)
|
|
|
|
|
.map(s => s.src);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
browser.runtime.sendMessage({
|
|
|
|
|
id: 'analyze',
|
|
|
|
|
subject: { html },
|
|
|
|
|
source: 'content.js'
|
|
|
|
|
});
|
|
|
|
|
.filter(script => script.src)
|
|
|
|
|
.map(script => script.src);
|
|
|
|
|
|
|
|
|
|
browser.runtime.sendMessage({
|
|
|
|
|
id: 'analyze',
|
|
|
|
|
subject: { scripts },
|
|
|
|
|
subject: { html, scripts },
|
|
|
|
|
source: 'content.js'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var container = document.createElement('wappalyzerData');
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
|
|
|
|
|
container.setAttribute('id', 'wappalyzerData');
|
|
|
|
|
container.setAttribute('style', 'display: none');
|
|
|
|
|
|
|
|
|
|
var script = document.createElement('script');
|
|
|
|
|
|
|
|
|
|
script.setAttribute('id', 'wappalyzerEnvDetection');
|
|
|
|
|
script.setAttribute('src', browser.extension.getURL('js/inject.js'));
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
script.onload = () => {
|
|
|
|
|
addEventListener('message', event => {
|
|
|
|
|
if ( event.data.id !== 'js' ) {
|
|
|
|
|
return;
|
|
|
|
|
var js = event.data.js ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
browser.runtime.sendMessage({
|
|
|
|
|
id: 'analyze',
|
|
|
|
|
subject: { js },
|
|
|
|
|
subject: {
|
|
|
|
|
js: event.data.js
|
|
|
|
|
},
|
|
|
|
|
source: 'content.js'
|
|
|
|
|
});
|
|
|
|
|
}), true);
|
|
|
|
|
|
|
|
|
|
var env = event.target.childNodes[0].nodeValue;
|
|
|
|
|
|
|
|
|
|
document.documentElement.removeChild(container);
|
|
|
|
|
document.documentElement.removeChild(script);
|
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
|
|
env = env.split(' ').slice(0, 500);
|
|
|
|
|
|
|
|
|
|
browser.runtime.sendMessage({
|
|
|
|
|
id: 'analyze',
|
|
|
|
|
subject: { env },
|
|
|
|
|
( chrome || browser ).runtime.sendMessage({
|
|
|
|
|
id: 'init_js',
|
|
|
|
|
subject: {},
|
|
|
|
|
source: 'content.js'
|
|
|
|
|
}, response => {
|
|
|
|
|
postMessage({
|
|
|
|
|
id: 'patterns',
|
|
|
|
|
patterns: response.patterns
|
|
|
|
|
}, '*');
|
|
|
|
|
});
|
|
|
|
|
}), true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
script.setAttribute('id', 'wappalyzer');
|
|
|
|
|
script.setAttribute('src', browser.extension.getURL('js/inject.js'));
|
|
|
|
|
|
|
|
|
|
document.documentElement.appendChild(container);
|
|
|
|
|
document.documentElement.appendChild(script);
|
|
|
|
|
} catch(e) {
|
|
|
|
|
document.body.appendChild(script);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|