diff --git a/src/drivers/npm/README.md b/src/drivers/npm/README.md index 29078d2f3..3214b693c 100644 --- a/src/drivers/npm/README.md +++ b/src/drivers/npm/README.md @@ -49,6 +49,8 @@ node index.js [url] [options] const Wappalyzer = require('./driver'); const Browser = require('./browsers/zombie'); +const url = 'https://www.wappalyzer.com; + const options = { debug: false, delay: 500, @@ -61,10 +63,17 @@ const options = { htmlMaxRows: 2000, }; -const wappalyzer = new Wappalyzer(Browser, 'https://www.wappalyzer.com', options); +const wappalyzer = new Wappalyzer(Browser, url, options); + +// Optional: capture log output +// wappalyzer.on('log', params => { +// const { message, source, type } = params; +// }); -// Optionally override the default logger -// wappalyzer.log = (message, source, type) => console.log(message); +// Optional: do something on page visit +// wappalyzer.on('visit', params => { +// const { browser, pageUrl } = params; +// }); wappalyzer.analyze() .then(json => { diff --git a/src/drivers/npm/browsers/zombie.js b/src/drivers/npm/browsers/zombie.js index 0e091d697..28f6ba3ce 100644 --- a/src/drivers/npm/browsers/zombie.js +++ b/src/drivers/npm/browsers/zombie.js @@ -25,6 +25,8 @@ class ZombieBrowser extends Browser { const resource = this.browser.resources.length ? this.browser.resources.filter(_resource => _resource.response).shift() : null; + this.window = this.browser.window; + this.document = this.browser.document; this.headers = this.getHeaders(); this.statusCode = resource ? resource.response.status : 0; this.contentType = this.headers['content-type'] ? this.headers['content-type'].shift() : null; diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index cf4bfce61..53746b326 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -48,6 +48,7 @@ class Driver { this.analyzedPageUrls = {}; this.apps = []; this.meta = {}; + this.listeners = {}; this.Browser = Browser; @@ -65,6 +66,20 @@ class Driver { process.on('uncaughtException', e => this.wappalyzer.log(`Uncaught exception: ${e.message}`, 'driver', 'error')); } + on(event, callback) { + if (!this.listeners[event]) { + this.listeners[event] = []; + } + + this.listeners[event].push(callback); + } + + emit(event, params) { + if (this.listeners[event]) { + this.listeners[event].forEach(listener => listener(params)); + } + } + analyze() { this.time = { start: new Date().getTime(), @@ -78,6 +93,8 @@ class Driver { if (this.options.debug) { console.log(`[wappalyzer ${type}]`, `[${source}]`, message); } + + this.emit('log', { message, source, type }); } displayApps(detected, meta) { @@ -150,11 +167,11 @@ class Driver { // Validate response if (!browser.statusCode) { - reject(new Error('NO_RESPONSE')); + return reject(new Error('NO_RESPONSE')); } if (browser.statusCode !== 200) { - reject(new Error('RESPONSE_NOT_OK')); + return reject(new Error('RESPONSE_NOT_OK')); } if (!browser.contentType || !/\btext\/html\b/.test(browser.contentType)) { @@ -188,6 +205,8 @@ class Driver { }, [], ); + this.emit('visit', { browser, pageUrl }); + return resolve(reducedLinks); } diff --git a/src/drivers/npm/npm-shrinkwrap.json b/src/drivers/npm/npm-shrinkwrap.json index 0152d40c4..238a9bf90 100644 --- a/src/drivers/npm/npm-shrinkwrap.json +++ b/src/drivers/npm/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "wappalyzer", - "version": "5.6.0", + "version": "5.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/drivers/npm/package.json b/src/drivers/npm/package.json index 0067fa0d5..14a7c6645 100644 --- a/src/drivers/npm/package.json +++ b/src/drivers/npm/package.json @@ -2,7 +2,7 @@ "name": "wappalyzer", "description": "Uncovers the technologies used on websites", "homepage": "https://github.com/AliasIO/Wappalyzer", - "version": "5.6.1", + "version": "5.6.2", "author": "Elbert Alias", "license": "GPL-3.0", "repository": { @@ -12,9 +12,10 @@ "main": "driver.js", "files": [ "apps.json", + "browser.js", "browsers/zombie.js", - "index.js", "driver.js", + "index.js", "wappalyzer.js" ], "bin": { diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index 1336809d4..c1703ed5c 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -339,8 +339,8 @@ wappalyzer.driver.ping = async (hostnameCache = {}, adCache = []) => { }); } else if (version !== previousVersion && upgradeMessage) { openTab({ - url: `${wappalyzer.config.websiteURL}upgraded?v${version}`, - background: true, + url: `${wappalyzer.config.websiteURL}upgraded?v${version}`, + background: true, }); } diff --git a/src/drivers/webextension/manifest.json b/src/drivers/webextension/manifest.json index bb1146b10..3f12953c8 100644 --- a/src/drivers/webextension/manifest.json +++ b/src/drivers/webextension/manifest.json @@ -4,7 +4,7 @@ "author": "Elbert Alias", "homepage_url": "https://www.wappalyzer.com", "description": "Identify web technologies", - "version": "5.6.1", + "version": "5.6.2", "default_locale": "en", "manifest_version": 2, "icons": {