Merge pull request #1 from ElbertF/master

Merge ElbertF/Wappalyzer into ahug/Wappalyzer
main
Andreas Hug 12 years ago
commit 887062d492

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 260 B

@ -13,64 +13,64 @@ var wappalyzer = (function() {
* Application class
*/
var Application = function(app, detected) {
var self = this;
self.app = app;
self.confidence = {};
self.confidenceTotal = 0;
self.detected = Boolean(detected);
self.version = '';
self.versions = [];
this.app = app;
this.confidence = {};
this.confidenceTotal = 0;
this.detected = Boolean(detected);
this.version = '';
this.versions = [];
};
Application.prototype = {
/**
* Calculate confidence total
*/
self.getConfidence = function() {
getConfidence: function() {
var total = 0;
for ( id in self.confidence ) {
total += self.confidence[id];
for ( id in this.confidence ) {
total += this.confidence[id];
}
return self.confidenceTotal = Math.min(total, 100);
}
return this.confidenceTotal = Math.min(total, 100);
},
/**
* Resolve version number (find the longest version number that contains all shorter detected version numbers)
*/
self.getVersion = function() {
var next, resolved;
getVersion: function() {
var i, next, resolved;
if ( !self.versions.length ) {
if ( !this.versions.length ) {
return;
}
self.versions.sort(function(a, b) {
this.versions.sort(function(a, b) {
return a.length > b.length ? 1 : ( a.length < b.length ? -1 : 0 );
});
resolved = self.versions[0];
resolved = this.versions[0];
for ( i in self.versions ) {
for ( i in this.versions ) {
next = parseInt(i) + 1;
if ( next < self.versions.length ) {
if ( self.versions[next].indexOf(self.versions[i]) !== -1 ) {
resolved = self.versions[next];
if ( next < this.versions.length ) {
if ( this.versions[next].indexOf(this.versions[i]) !== -1 ) {
resolved = this.versions[next];
} else {
break;
}
}
}
return self.version = resolved;
}
return this.version = resolved;
},
self.setDetected = function(pattern, type, value, key) {
self.detected = true;
setDetected: function(pattern, type, value, key) {
this.detected = true;
// Set confidence level
self.confidence[type + ' ' + ( key ? key + ' ' : '' ) + pattern.regex] = pattern.confidence ? pattern.confidence : 100;
this.confidence[type + ' ' + ( key ? key + ' ' : '' ) + pattern.regex] = pattern.confidence ? pattern.confidence : 100;
// Detect version number
if ( pattern.version ) {
@ -79,13 +79,20 @@ var wappalyzer = (function() {
matches = pattern.regex.exec(value)
;
w.log({ matches: matches, version: version });
if ( matches ) {
matches.map(function(match, i) {
// Parse ternary operator
var ternary = new RegExp('\\\\' + i + '\\?([^:]+):(.+)$').exec(version);
if ( ternary && ternary.length === 3 ) {
w.log({ match: match, i: i, ternary: ternary });
version = version.replace(ternary[0], match ? ternary[1] : ternary[2]);
w.log({ version: version });
}
// Replace back references
@ -93,14 +100,43 @@ var wappalyzer = (function() {
});
if ( version ) {
self.versions.push(version);
this.versions.push(version);
}
self.getVersion();
this.getVersion();
}
}
}
}
};
var Profiler = function() {
this.regexCount = 0;
this.startTime = new Date().getTime();
this.lastTime = new Date().getTime();
this.slowest = { duration: null, app: '', type: '', pattern: '' };
this.timedOut = false;
};
Profiler.prototype = {
checkPoint: function(app, type, regex) {
var duration = new Date().getTime() - this.lastTime;
if ( !this.slowest.duration || duration > this.slowest.duration ) {
this.slowest.duration = duration;
this.slowest.app = app;
this.slowest.type = type;
this.slowest.regex = regex;
}
this.lastTime = new Date().getTime();
this.timedOut = this.getDuration() > 1000;
},
getDuration: function() {
return new Date().getTime() - this.startTime;
}
};
/**
* Call driver functions
@ -172,15 +208,9 @@ var wappalyzer = (function() {
config: {
environment: 'dev', // dev | live
version: false,
websiteURL: 'http://wappalyzer.com/',
twitterURL: 'https://twitter.com/Wappalyzer',
githubURL: 'https://github.com/ElbertF/Wappalyzer',
firstRun: false,
upgraded: false
},
/**
@ -214,19 +244,7 @@ var wappalyzer = (function() {
}
// Initialize driver
driver('init', function() {
if ( w.config.firstRun ) {
driver('goToURL', { url: w.config.websiteURL + 'installed', medium: 'install' });
w.config.firstRun = false;
}
if ( w.config.upgraded ) {
driver('goToURL', { url: w.config.websiteURL + 'upgraded', medium: 'upgrade' });
w.config.upgraded = false;
}
});
driver('init');
},
/**
@ -235,10 +253,7 @@ var wappalyzer = (function() {
analyze: function(hostname, url, data) {
var
i, j, app, confidence, type, regexMeta, regexScript, match, content, meta, header, version,
profiler = {
regexCount: 0,
startTime: new Date().getTime()
},
profiler = new Profiler(),
apps = {}
;
@ -257,13 +272,21 @@ var wappalyzer = (function() {
}
for ( app in w.apps ) {
// Exit loop after one second to prevent CPU hogging
// Remaining patterns will not be evaluated
if ( profiler.timedOut ) {
w.log('Timeout, exiting loop');
break;
}
apps[app] = w.detected[url] && w.detected[url][app] ? w.detected[url][app] : new Application(app);
for ( type in w.apps[app] ) {
switch ( type ) {
case 'url':
parse(w.apps[app][type]).map(function(pattern) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( pattern.regex.test(url) ) {
apps[app].setDetected(pattern, type, url);
@ -277,7 +300,7 @@ var wappalyzer = (function() {
}
parse(w.apps[app][type]).map(function(pattern) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( pattern.regex.test(data[type]) ) {
apps[app].setDetected(pattern, type, data[type]);
@ -293,10 +316,10 @@ var wappalyzer = (function() {
regexScript = new RegExp('<script[^>]+src=("|\')([^"\']+)', 'ig');
parse(w.apps[app][type]).map(function(pattern) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
while ( match = regexScript.exec(data.html) ) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( pattern.regex.test(match[2]) ) {
apps[app].setDetected(pattern, type, match[2]);
@ -310,19 +333,17 @@ var wappalyzer = (function() {
break;
}
profiler.regexCount ++;
regexMeta = /<meta[^>]+>/ig;
while ( match = regexMeta.exec(data.html) ) {
for ( meta in w.apps[app][type] ) {
profiler.regexCount ++;
profiler.checkPoint(app, type, regexMeta);
if ( new RegExp('name=["\']' + meta + '["\']', 'i').test(match) ) {
content = match.toString().match(/content=("|')([^"']+)("|')/i);
parse(w.apps[app].meta[meta]).map(function(pattern) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( content && content.length === 4 && pattern.regex.test(content[2]) ) {
apps[app].setDetected(pattern, type, content[2], meta);
@ -340,7 +361,7 @@ var wappalyzer = (function() {
for ( header in w.apps[app].headers ) {
parse(w.apps[app][type][header]).map(function(pattern) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( typeof data[type][header] === 'string' && pattern.regex.test(data[type][header]) ) {
apps[app].setDetected(pattern, type, data[type][header], header);
@ -356,7 +377,7 @@ var wappalyzer = (function() {
parse(w.apps[app][type]).map(function(pattern) {
for ( i in data[type] ) {
profiler.regexCount ++;
profiler.checkPoint(app, type, pattern.regex);
if ( pattern.regex.test(data[type][i]) ) {
apps[app].setDetected(pattern, type, data[type][i]);
@ -369,7 +390,8 @@ var wappalyzer = (function() {
}
}
w.log('Tested ' + profiler.regexCount + ' regular expressions in ' + ( ( ( new Date ).getTime() - profiler.startTime ) / 1000 ) + 's');
w.log('[ PROFILER ] Tested ' + profiler.regexCount + ' regular expressions in ' + ( profiler.getDuration() / 1000 ) + 's');
w.log('[ PROFILER ] Slowest pattern took ' + ( profiler.slowest.duration / 1000 ) + 's: ' + profiler.slowest.app + ' | ' + profiler.slowest.type + ' | ' + profiler.slowest.regex);
for ( app in apps ) {
if ( !apps[app].detected ) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -8,7 +8,6 @@
<script src="js/wappalyzer.js"></script>
<script src="js/defaults.js"></script>
<script src="js/driver.js"></script>
<script src="js/background.js"></script>
</head>
<body>
</body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Some files were not shown because too many files have changed in this diff Show More