You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.7 KiB

12 years ago
/**
* Bookmarklet driver
*/
(function() {
if ( wappalyzer == null ) return;
12 years ago
var
w = wappalyzer,
debug = true
d = window.document,
container = d.getElementById('wappalyzer-container'),
domain = window.top.location.host,
url = window.top.location.href,
categoryNames = {
1: 'CMS',
2: 'Message Board',
3: 'Database Manager',
4: 'Documentation Tool',
5: 'Widget',
6: 'Web Shop',
7: 'Photo Gallery',
8: 'Wiki',
9: 'Hosting Panel',
10: 'Analytics',
11: 'Blog',
12: 'Javascript Framework',
13: 'Issue Tracker',
14: 'Video Player',
15: 'Comment System',
16: 'Captcha',
17: 'Font Script',
18: 'Web Framework',
19: 'Miscellaneous',
20: 'Editor',
21: 'LMS',
22: 'Web Server',
23: 'Cache Tool',
24: 'Rich Text Editor',
25: 'Javascript Graphics',
26: 'Mobile Framework',
27: 'Programming Language',
28: 'Operating System',
29: 'Search Engine'
}
;
w.driver = {
/**
* Log messages to console
*/
log: function(args) {
12 years ago
if ( debug && console != null && console[args.type] != null ) {
console[args.type](args.message);
}
},
/**
* Initialize
*/
init: function() {
12 years ago
w.driver.getEnvironmentVars();
w.driver.getResponseHeaders();
},
getEnvironmentVars: function() {
w.log('func: getEnvironmentVars');
var env = new Array;
12 years ago
for ( i in window ) { env.push(i); }
w.analyze(domain, url, { html: d.documentElement.innerHTML, env: env });
12 years ago
},
getResponseHeaders: function() {
w.log('func: getResponseHeaders');
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 && xhr.status ) {
var headers = xhr.getAllResponseHeaders().split("\n");
if ( headers.length > 0 && headers[0] != '' ) {
w.log('responseHeaders: ' + xhr.getAllResponseHeaders());
var responseHeaders = {};
headers.forEach(function(line) {
if ( line ) {
name = line.substring(0, line.indexOf(': '));
value = line.substring(line.indexOf(': ') + 2, line.length - 1);
responseHeaders[name] = value;
}
});
w.analyze(domain, url, { headers: responseHeaders });
12 years ago
}
}
}
xhr.send();
},
/**
* Display apps
*/
displayApps: function() {
w.log('func: diplayApps');
12 years ago
var
category,
html
;
12 years ago
html =
'<a id="wappalyzer-close" href="javascript: window.document.body.removeChild(window.document.getElementById(\'wappalyzer-container\')); void(0);">' +
'Close' +
12 years ago
'</a>' +
'<div id="wappalyzer-apps">'
;
if ( w.detected[url] != null && w.detected[url].length ) {
w.detected[url].map(function(app, i) {
12 years ago
html +=
'<div class="wappalyzer-app' + ( !i ? ' wappalyzer-first' : '' ) + '">' +
'<a target="_blank" class="wappalyzer-application" href="' + w.config.websiteURL + 'applications/' + app.toLowerCase().replace(/ /g, '-').replace(/[^a-z0-9-]/g, '') + '">' +
'<strong>' +
12 years ago
'<img src="' + w.config.websiteURL + 'bookmarklet/images/icons/' + app + '.png" width="16" height="16"/> ' + app +
'</strong>' +
'</a>'
;
for ( cat in w.apps[app].cats ) {
12 years ago
category = w.apps[app].cats[cat];
html += '<a target="_blank" class="wappalyzer-category" href="' + w.config.websiteURL + 'categories/' + w.categories[category] + '">' + categoryNames[category] + '</a>';
}
html += '</div>';
});
13 years ago
} else {
12 years ago
html += '<div id="wappalyzer-empty">No applications detected</div>';
}
13 years ago
12 years ago
html += '</div>';
13 years ago
12 years ago
container.innerHTML = html;
},
/**
* Go to URL
*/
goToURL: function(args) {
window.open(args.url);
}
};
w.init();
})();