Added button to analyze headers in Chrome driver

main
ElbertF 12 years ago
parent 7f50cc97cd
commit ab39c29398

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -6,7 +6,6 @@
chrome.extension.sendRequest({ id: 'analyze', subject: { html: document.documentElement.innerHTML } });
c.getEnvironmentVars();
c.getResponseHeaders();
},
log: function(message) {
@ -60,37 +59,6 @@
} catch(e) {
c.log('Error: ' + e);
}
},
getResponseHeaders: function() {
var xhr = new XMLHttpRequest();
xhr.open('GET', window.location, true);
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 && xhr.status ) {
var headers = xhr.getAllResponseHeaders().split("\n");
if ( headers.length > 0 && headers[0] != '' ) {
c.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;
}
});
chrome.extension.sendRequest({ id: 'analyze', subject: { headers: responseHeaders } });
}
}
}
xhr.send();
}
}

@ -42,6 +42,14 @@
w.analyze(tab.url, tab.url, request.subject);
for ( subject in request.subject ) {
tabCache[tab.id].analyzed.push(subject);
}
break;
case 'fetch_headers':
chrome.tabs.executeScript(request.tab.id, { file: 'js/headers.js' });
break;
case 'get_apps':
sendResponse({ tabCache: tabCache[request.tab.id] });
@ -72,10 +80,16 @@
displayApps: function() {
var count = w.detected[tab.url].length.toString();
tabCache[tab.id] = {
count: count,
appsDetected: w.detected[tab.url]
};
if ( tabCache[tab.id] == null ) {
tabCache[tab.id] = {
count: 0,
appsDetected: [],
analyzed: []
};
}
tabCache[tab.id].count = count;
tabCache[tab.id].appsDetected = w.detected[tab.url];
if ( count > 0 ) {
chrome.browserAction.setBadgeText({ tabId: tab.id, text: count });

@ -0,0 +1,46 @@
(function() {
var c = {
init: function() {
c.log('init');
c.getResponseHeaders();
},
log: function(message) {
chrome.extension.sendRequest({ id: 'log', message: '[ content.js ] ' + message });
},
getResponseHeaders: function() {
var xhr = new XMLHttpRequest();
xhr.open('GET', window.location, true);
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 && xhr.status ) {
var headers = xhr.getAllResponseHeaders().split("\n");
if ( headers.length > 0 && headers[0] != '' ) {
c.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;
}
});
chrome.extension.sendRequest({ id: 'analyze', subject: { headers: responseHeaders } });
}
}
}
xhr.send();
}
}
c.init();
})();

@ -4,7 +4,7 @@
"32": "images/icon_32.png",
"128": "images/icon_128.png"
},
"version": "0.8",
"version": "0.9",
"description": "Identifies software on the web",
"browser_action": {
"default_icon": "images/icon_32.png",
@ -15,7 +15,7 @@
"content_scripts": [{
"matches": [ "http://*/*", "https://*/*" ],
"js": [
"js/content.js"
"js/content.js"
],
"run_at": "document_idle"
}],

@ -57,3 +57,19 @@ img {
font-style: italic;
text-align: center;
}
#analyze-headers {
border: 1px solid #eee;
border-radius: 3px;
cursor: pointer;
display: none;
line-height: 30px;
margin-top: 7px;
text-align: center;
}
#analyze-headers.pending {
background: url('images/pending.gif') center center no-repeat;
color: #999;
text-indent: -999px;
}

@ -15,38 +15,76 @@
<body>
<div id="detected-apps"></div>
<div id="analyze-headers">Analyze headers</div>
<script>
$('#detected-apps').html('<div class="empty">No applications detected.</div>');
chrome.tabs.getSelected(null, function(tab) {
chrome.extension.sendRequest({ id: 'get_apps', tab: tab }, function(response) {
if ( response.tabCache.count > 0 ) {
$('#detected-apps').html('');
response.tabCache.appsDetected.map(function(appName) {
html =
'<div class="detected-app">' +
'<a target="_blank" href="http://wappalyzer.com/applications/' + encodeURIComponent(appName) + '">' +
'<img src="images/icons/' + appName + '.png"/>' +
'<span class="label">' + appName + '</span>' +
'</a>';
wappalyzer.apps[appName].cats.map(function(cat) {
html +=
'<a target="_blank" href="http://wappalyzer.com/categories/' + wappalyzer.categories[cat] + '">' +
'<span class="category">' + categoryNames[cat] + '</span>' +
'</a>';
});
(function() {
var popup = {
pollHeaders: null,
init: function() {
chrome.tabs.getSelected(null, function(tab) {
if ( tab.url.match(/https?:\/\//) ) {
$('#detected-apps').html('<div class="empty">No applications detected.</div>');
$('#analyze-headers').show().click(function() {
$(this).addClass('pending');
chrome.extension.sendRequest({ id: 'fetch_headers', tab: tab });
popup.pollHeaders = setInterval(popup.displayApps, 100);
});
} else {
$('#detected-apps').html('<div class="empty">Nothing to do here.</div>');
$('#analyze-headers').hide();
}
});
html +=
'</a>' +
'</div>';
popup.displayApps();
},
$('#detected-apps').append(html);
displayApps: function() {
chrome.tabs.getSelected(null, function(tab) {
chrome.extension.sendRequest({ id: 'get_apps', tab: tab }, function(response) {
if ( response.tabCache.analyzed.indexOf('headers') > 0 ) {
clearTimeout(popup.pollHeaders);
$('#analyze-headers').removeClass('pending');
}
if ( response.tabCache.count > 0 ) {
$('#detected-apps').html('');
response.tabCache.appsDetected.map(function(appName) {
html =
'<div class="detected-app">' +
'<a target="_blank" href="http://wappalyzer.com/applications/' + encodeURIComponent(appName) + '">' +
'<img src="images/icons/' + appName + '.png"/>' +
'<span class="label">' + appName + '</span>' +
'</a>';
wappalyzer.apps[appName].cats.map(function(cat) {
html +=
'<a target="_blank" href="http://wappalyzer.com/categories/' + wappalyzer.categories[cat] + '">' +
'<span class="category">' + categoryNames[cat] + '</span>' +
'</a>';
});
html +=
'</a>' +
'</div>';
$('#detected-apps').append(html);
});
}
});
});
}
});
});
}
popup.init();
})();
</script>
</body>
</html>

Loading…
Cancel
Save