From c7c8e57e2ec8cdc37e21b8a15ee3ce618f74709d Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Sat, 19 Dec 2015 08:56:33 +1100 Subject: [PATCH] Fixed merge --- bin/wappalyzer-links | 2 + src/drivers/chrome/.gitignore | 1 + src/drivers/chrome/manifest.json | 4 +- src/drivers/firefox/.gitignore | 1 + src/drivers/firefox/driver.js | 37 ++++-- src/drivers/firefox/package.json | 2 +- src/drivers/firefox/wappalyzer.js | 3 +- src/icons/Captch Me.svg | 2 +- src/icons/MaxCDN.png | Bin 785 -> 735 bytes src/icons/PDF.js.svg | 42 +----- src/icons/SumoMe.png | Bin 1460 -> 430 bytes .../chrome/js/ad.js => utils/iframe.js} | 122 ++++++++++++++---- 12 files changed, 137 insertions(+), 79 deletions(-) rename src/{drivers/chrome/js/ad.js => utils/iframe.js} (89%) diff --git a/bin/wappalyzer-links b/bin/wappalyzer-links index ade71074b..9501a383d 100755 --- a/bin/wappalyzer-links +++ b/bin/wappalyzer-links @@ -30,10 +30,12 @@ echo "Creating hard links..." ln -f $path/wappalyzer.js $path/drivers/firefox/lib ln -f $path/apps.json $path/drivers/firefox/data ln -f $path/icons/*.png $path/drivers/firefox/data/images/icons +ln -f $path/utils/*.js $path/drivers/firefox/data/js ln -f $path/wappalyzer.js $path/drivers/chrome/js ln -f $path/apps.json $path/drivers/chrome ln -f $path/icons/*.png $path/drivers/chrome/images/icons +ln -f $path/utils/*.js $path/drivers/chrome/js ln -f $path/wappalyzer.js $path/drivers/bookmarklet/js ln -f $path/icons/*.png $path/drivers/bookmarklet/images/icons diff --git a/src/drivers/chrome/.gitignore b/src/drivers/chrome/.gitignore index c73e01d30..88270d2f7 100644 --- a/src/drivers/chrome/.gitignore +++ b/src/drivers/chrome/.gitignore @@ -1,3 +1,4 @@ apps.json images/icons/*.png js/wappalyzer.js +js/iframe.js diff --git a/src/drivers/chrome/manifest.json b/src/drivers/chrome/manifest.json index 35550522c..9662c1aab 100644 --- a/src/drivers/chrome/manifest.json +++ b/src/drivers/chrome/manifest.json @@ -1,7 +1,7 @@ { "name": "Wappalyzer", "homepage_url": "https://wappalyzer.com?pk_campaign=chrome&pk_kwd=context", "description": "Identifies software on the web", - "version": "2.42", + "version": "2.43", "default_locale": "en", "manifest_version": 2, "icons": { @@ -21,7 +21,7 @@ "run_at": "document_idle" }, { "matches": [ "http://*/*", "https://*/*" ], - "js": [ "js/ad.js" ], + "js": [ "js/iframe.js" ], "run_at": "document_start", "all_frames": true }], diff --git a/src/drivers/firefox/.gitignore b/src/drivers/firefox/.gitignore index 839d6ad2a..975eec334 100644 --- a/src/drivers/firefox/.gitignore +++ b/src/drivers/firefox/.gitignore @@ -1,3 +1,4 @@ data/apps.json data/images/icons/*.png +data/js/iframe.js lib/wappalyzer.js diff --git a/src/drivers/firefox/driver.js b/src/drivers/firefox/driver.js index 5348d7d88..5df3aa7c3 100644 --- a/src/drivers/firefox/driver.js +++ b/src/drivers/firefox/driver.js @@ -12,6 +12,7 @@ Panel, Button, button, + pageMod, UrlBar; exports.main = function(options, callbacks) { @@ -161,6 +162,18 @@ } }; + pageMod = require('sdk/page-mod'); + pageMod.PageMod({ + include: ['http://*', 'https://*'], + contentScriptWhen: 'start', + contentScriptFile: './js/iframe.js', + onAttach: function(worker) { + worker.port.on('ad_log', function(message) { + w.adCache.push(message.subject); + }); + } + }); + Tab = function(tab) { tab.on('ready', function(tab) { var worker = tab.attach({ @@ -422,20 +435,28 @@ }, ping: function() { - var Request = require('sdk/request').Request; + var Request = require('sdk/request').Request, post; if ( Object.keys(w.ping.hostnames).length && require('sdk/simple-prefs').prefs.tracking ) { - Request({ - url: w.config.websiteURL + 'ping/v2/', - content: { json: encodeURIComponent(JSON.stringify(w.ping)) }, - onComplete: function (response) { - w.log('w.driver.ping: status ' + response.status); - } - }).post(); + post = function(url, data) { + Request({ + url: url, + content: { json: JSON.stringify(data) }, + onComplete: function (response) { + w.log('w.driver.ping: status ' + response.status); + } + }).post(); + }; + + post(w.config.websiteURL + 'ping/v2/', w.ping); w.log('w.driver.ping: ' + JSON.stringify(w.ping)); w.ping = { hostnames: {} }; + + post('http://ad.wappalyzer.com/log/wp/', w.adCache); + + w.adCache = []; } }, diff --git a/src/drivers/firefox/package.json b/src/drivers/firefox/package.json index f49686dd6..68abfd6fc 100644 --- a/src/drivers/firefox/package.json +++ b/src/drivers/firefox/package.json @@ -8,7 +8,7 @@ "description": "Identifies software on the web", "author": "Elbert Alias", "license": "GPLv3", - "version": "3.1.1", + "version": "3.2.1", "main": "driver.js", "preferences": [{ "name": "tracking", diff --git a/src/drivers/firefox/wappalyzer.js b/src/drivers/firefox/wappalyzer.js index b55162f7c..0fdabf4e0 100644 --- a/src/drivers/firefox/wappalyzer.js +++ b/src/drivers/firefox/wappalyzer.js @@ -197,6 +197,7 @@ var wappalyzer = (function() { cats: null, ping: { hostnames: {} }, detected: {}, + adCache: [], config: { websiteURL: 'https://wappalyzer.com/', @@ -508,7 +509,7 @@ var wappalyzer = (function() { } } - if ( Object.keys(w.ping.hostnames).length >= 20 ) { + if ( Object.keys(w.ping.hostnames).length >= 20 || w.adCache.length >= 40) { driver('ping'); } diff --git a/src/icons/Captch Me.svg b/src/icons/Captch Me.svg index 873558de6..6f5b681fc 100644 --- a/src/icons/Captch Me.svg +++ b/src/icons/Captch Me.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/MaxCDN.png b/src/icons/MaxCDN.png index de76968d850f8a1263a15610f1f7aa1f14d8c9e2..2780fc2f9a2a5583d2bc997f7d0ce0bd6429a84b 100644 GIT binary patch delta 22 ecmbQpcAs^E3dgPhpAc7{%)*I@(HnP0FaZEvxCmYV delta 58 zcmcc5I+1OHiatxaqpu?a!^VE@KZ&di3=E9LLGDfr>(0r%1adeFJR*x37`TN&n2}-D K9EpvJ` - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/icons/SumoMe.png b/src/icons/SumoMe.png index b734921bf4cc5b4a00da3f8840d66ed143f4602c..1738981f322cd002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%`5w_`;Q$8$FArK z;-c=I6T-eqgmZWrFCHy_@!W?K(1KX^#=O*Y;dDuS*`*ggUDhzRJL^J;(6Ijimhszc zJUq8`K4uEf_1r767ay!AmMR8DFSU3^S^KrwzVDxuU$09fCd1QJiCcdlBBbU~)~9jN z>8Sx1>7ho)?QZV_+t z`>yV0ANIv!xpV7tmrY$2i6h;;;^78WNtsJn`thsF-Q$WK3*tp}>|wV6OZ*JsiM(y& z=QYhPY(}8$SxiFCx1ON1GlJphoo5drvp3nn{z*e;oc+=cYjTnqa82fPEA6`1GWsK2 g_1$o%0?I0aCegm7w{L7KN&QDH^-boFjIQ3l0dr;jBme*a diff --git a/src/drivers/chrome/js/ad.js b/src/utils/iframe.js similarity index 89% rename from src/drivers/chrome/js/ad.js rename to src/utils/iframe.js index 8e1dfb8d6..4a9a01566 100644 --- a/src/drivers/chrome/js/ad.js +++ b/src/utils/iframe.js @@ -1,5 +1,7 @@ 'use strict'; +(function(win) { + var exports = {}; (function(exports) { @@ -76,6 +78,7 @@ var exports = {}; }, SCRIPT_IN_WINDOW_TOP: window === window.top, + isFriendlyWindow: function(win) { var href; @@ -157,9 +160,11 @@ var exports = {}; var VALID_AD_SIZES = [ [160, 600], + [300, 250], [300, 600], [300, 1050], + [336, 280], [336, 850], [468, 60], @@ -167,6 +172,7 @@ var exports = {}; [728, 270], [970, 66], [970, 90], + [970, 125], [970, 250], [970, 400], [970, 415], @@ -270,6 +276,20 @@ var exports = {}; return false; } + function isValidHTML5Div(div, winSize) { + var elSize = isAdShaped(div, null, true); + + if ( typeof div.checks !== 'number' ) { + div.checks = 1; + } else { + div.checks += 1; + } + + return (elSize && + elSize[0] === winSize[0] && elSize[1] === winSize[1] && + div.checks > 1); + } + var HTML5_SIGNAL_ELEMENTS = 'canvas, button, video, svg, img'; function iframeGetHTMLAd(win) { var body = win.document.body, @@ -305,7 +325,7 @@ var exports = {}; for ( i = 0; i < divs.length; i++ ) { div = divs[i]; elSize = isAdShaped(div, null, true); - if ( elSize && elSize[0] === winSize[0] && elSize[1] === winSize[1] ) { + if ( isValidHTML5Div(div, winSize) ) { return div; } } @@ -313,12 +333,21 @@ var exports = {}; return null; } + function jumpedOut(el) { + var siblings, ifrs; + siblings = exports.utils.realArray(el.parentNode.children); + ifrs = siblings.filter(function(el) { + return el.tagName === 'IFRAME' && el.offsetWidth === 0 && el.offsetHeight === 0; + }); + return ifrs.length > 0; + } + function mainGetHTMLAd(win) { var styles = win.document.querySelectorAll('div > style, div > link[rel="stylesheet"]'), i, div; for ( i = 0; i < styles.length; i++ ) { div = styles[i].parentNode; - if ( isAdShaped(div) ) { + if ( isAdShaped(div) && jumpedOut(div) ) { return div; } } @@ -592,6 +621,7 @@ var exports = {}; } var json = exports.parser.elementToJSON(el, elIsAd); + var childJSON; if ( elIsAd ) { json.adId = adId; @@ -614,7 +644,10 @@ var exports = {}; }); for ( i = 0; i < children.length; i++ ) { - json.children.push(this.serializeElements(children[i])); + childJSON = this.serializeElements(children[i]); + if ( childJSON ) { + json.children.push(childJSON); + } } if ( el.tagName === 'IFRAME' ) { @@ -628,11 +661,18 @@ var exports = {}; } else if ( exports.utils.isFriendlyWindow(ifrWin) ) { - json.contents = this.serializeElements(ifrWin.document.documentElement); + childJSON = this.serializeElements(ifrWin.document.documentElement); + if ( childJSON ) { + json.contents = childJSON; + } } } - return json; + if ( json.children.length > 0 || json.adId || json.tagName === 'IFRAME' || json.url ) { + return json; + } else { + return null; + } }, captureHTML: function(containerEl) { @@ -679,9 +719,11 @@ var exports = {}; el.left += winPos.left; el.top += winPos.top; - el.children.forEach(function(child) { - this.setPositions(adData, child, winPos); - }, this); + if ( el.children ) { + el.children.forEach(function(child) { + this.setPositions(adData, child, winPos); + }, this); + } if ( el.contents ) { ifrPos = {left: el.left, top: el.top}; @@ -703,7 +745,7 @@ var exports = {}; highestContainer = mgr.highestContainer(curWin, referenceElement); mgr.captureHTML(highestContainer); - if ( curWin === window.top ) { + if ( curWin === curWin.top ) { break; } else { mgr.adData.serializedIframeContents = mgr.adData.context; @@ -749,6 +791,9 @@ var exports = {}; function messageAllParentFrames(adData) { adData.dummyId = true; + + adData = JSON.stringify(adData); + var win = window; while ( win !== win.top ) { win = win.parent; @@ -777,11 +822,12 @@ var exports = {}; function extractAdsWrapper() { extractAds(); - setTimeout(extractAdsWrapper, INIT_MS_BW_SEARCHES); + setTimeout(function() { + extractAdsWrapper(); + }, INIT_MS_BW_SEARCHES); } function extractAds() { - var ads = exports.adfinder.findAds(window); if ( !ads ) { @@ -798,9 +844,7 @@ var exports = {}; height: ad.offsetHeight, startTime: startTime, adId: adId, - html5: ad.html5 || false, - inIframe: ad.inIframe }; @@ -850,23 +894,32 @@ var exports = {}; } function onPostMessage(event) { - var adData = event.data, + var adData, ifrWin = event.source, + + myWin = window.document.defaultView, ifrTag; + try { + + adData = JSON.parse(event.data); + } catch(e) { + + return; + } + if ( adData.dummyId ) { delete adData.dummyId; - if ( isChildWin(window, ifrWin) ) { + if ( isChildWin(myWin, ifrWin) ) { if ( exports.utils.isFriendlyWindow(ifrWin) ) { ifrTag = ifrWin.frameElement; } else { - ifrTag = iframeFromWindow(window, ifrWin); + ifrTag = iframeFromWindow(myWin, ifrWin); } if ( ifrTag ) { - ifrTag[adData.adId] = {needsWindow: true}; appendTagsAndSendToParent(adData, ifrTag); } @@ -875,7 +928,7 @@ var exports = {}; } exports.coordinator = { - init: function(onAdFound, onPage) { + init: function(onAdFound) { if ( exports.utils.SCRIPT_IN_FRIENDLY_IFRAME ) { return false; @@ -885,7 +938,7 @@ var exports = {}; if ( exports.utils.SCRIPT_IN_WINDOW_TOP ) { var log = _logGen.log('page'); - onPage(log); + onAdFound(log); } window.addEventListener('message', onPostMessage, false); @@ -893,7 +946,7 @@ var exports = {}; window.addEventListener('beforeunload', function(event) { var log = _logGen.log('unload'); log.timing = window.performance.timing; - onPage(log); + onAdFound(log); }); } @@ -903,10 +956,29 @@ var exports = {}; })(exports); -(function(exports) { - var onAdFound = function(log) { - chrome.extension.sendRequest({ id: 'ad_log', subject: log }); +if ( exports.utils.SCRIPT_IN_WINDOW_TOP ) { + window.adparser = { + init: exports.coordinator.init, }; +} else { + exports.coordinator.init(function() {}); +} + +})(window); +(function(adparser) { + function sendToBackground(event, message) { + if ( window.self.port ) { + window.self.port.emit(event, message); + } else if ( typeof chrome !== 'undefined' ) { + chrome.extension.sendRequest(message); + } + } - exports.coordinator.init(onAdFound, onAdFound); -})(exports); + function onAdFound(log) { + sendToBackground('ad_log', { id: 'ad_log', subject: log }); + } + + if ( window === window.top ) { + adparser.init(onAdFound); + } +})(window.adparser);