diff --git a/extensions/metasploit/config.yaml b/extensions/metasploit/config.yaml index 5d445f4d2..6c52a2f56 100644 --- a/extensions/metasploit/config.yaml +++ b/extensions/metasploit/config.yaml @@ -33,6 +33,6 @@ beef: {os: 'bt5r3', path: '/opt/metasploit/msf3/'}, {os: 'bt5', path: '/opt/framework3/msf3/'}, {os: 'backbox', path: '/opt/metasploit3/msf3/'}, - {os: 'win', path: 'c:\metasploit\msf3\'}, + {os: 'win', path: 'c:\\metasploit-framework\\'}, {os: 'custom', path: ''} ] diff --git a/extensions/metasploit/rpcclient.rb b/extensions/metasploit/rpcclient.rb index 7b7eacd25..b0f62fd6c 100644 --- a/extensions/metasploit/rpcclient.rb +++ b/extensions/metasploit/rpcclient.rb @@ -36,10 +36,12 @@ module Metasploit #auto start msfrpcd if (@config['auto_msfrpcd'] || false) launch_msf = '' + msf_os = '' @config['msf_path'].each do |path| if File.exist?(path['path'] + 'msfrpcd') launch_msf = path['path'] + 'msfrpcd' print_info 'Found msfrpcd: ' + launch_msf + msf_os = path['os'] end end if (launch_msf.length > 0) @@ -53,32 +55,35 @@ module Metasploit end msf_url += opts[:host] + ':' + opts[:port].to_s() + opts[:uri] + if msf_os.eql? "win" + print_info 'Metasploit auto-launch is currently not supported in BeEF on MS Windows.' + else + child = IO.popen([launch_msf, "-f", argssl, "-P" , @config['pass'], "-U" , @config['user'], "-u" , opts[:uri], "-a" , opts[:host], "-p" , opts[:port].to_s()], 'r+') - child = IO.popen([launch_msf, "-f", argssl, "-P" , @config['pass'], "-U" , @config['user'], "-u" , opts[:uri], "-a" , opts[:host], "-p" , opts[:port].to_s()], 'r+') - - print_info 'Attempt to start msfrpcd, this may take a while. PID: ' + child.pid.to_s + print_info 'Attempt to start msfrpcd, this may take a while. PID: ' + child.pid.to_s - #Give daemon time to launch - #poll and giveup after timeout - retries = @config['auto_msfrpcd_timeout'] - uri = URI(msf_url) - http = Net::HTTP.new(uri.host, uri.port) + #Give daemon time to launch + #poll and giveup after timeout + retries = @config['auto_msfrpcd_timeout'] + uri = URI(msf_url) + http = Net::HTTP.new(uri.host, uri.port) - if opts[:ssl] - http.use_ssl = true - end - if not @config['ssl_verify'] - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - headers = { - 'Content-Type' => "binary/message-pack" - } - path = uri.path.empty? ? "/" : uri.path - begin - sleep 1 - code = http.head(path, headers).code.to_i - rescue Exception - retry if (retries -= 1) > 0 + if opts[:ssl] + http.use_ssl = true + end + if not @config['ssl_verify'] + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + end + headers = { + 'Content-Type' => "binary/message-pack" + } + path = uri.path.empty? ? "/" : uri.path + begin + sleep 1 + code = http.head(path, headers).code.to_i + rescue Exception + retry if (retries -= 1) > 0 + end end else print_error 'Please add a custom path for msfrpcd to the config-file.'