From 2d27266fc91e82ba61dd27f69920e7d9e9b790c5 Mon Sep 17 00:00:00 2001 From: bmantra Date: Wed, 6 Feb 2013 19:22:12 +0100 Subject: [PATCH 1/3] added message that metasploit auto launch is not available on MS Windows --- extensions/metasploit/rpcclient.rb | 51 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/extensions/metasploit/rpcclient.rb b/extensions/metasploit/rpcclient.rb index 7b7eacd25..d024f831d 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 'BeEF auto-connect with metasploit is currently not supported 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.' From f879584f1b142fdc979f371e3a2545ba5393bd78 Mon Sep 17 00:00:00 2001 From: bmantra Date: Wed, 6 Feb 2013 19:37:31 +0100 Subject: [PATCH 2/3] changed windows default path and changed message --- extensions/metasploit/config.yaml | 4 ++-- extensions/metasploit/rpcclient.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/metasploit/config.yaml b/extensions/metasploit/config.yaml index 5d445f4d2..7303ddad2 100644 --- a/extensions/metasploit/config.yaml +++ b/extensions/metasploit/config.yaml @@ -25,7 +25,7 @@ beef: ssl_verify: true callback_host: "127.0.0.1" autopwn_url: "autopwn" - auto_msfrpcd: false + auto_msfrpcd: true auto_msfrpcd_timeout: 120 msf_path: [ {os: 'osx', path: '/opt/local/msf/'}, @@ -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 d024f831d..b0f62fd6c 100644 --- a/extensions/metasploit/rpcclient.rb +++ b/extensions/metasploit/rpcclient.rb @@ -56,7 +56,7 @@ module Metasploit msf_url += opts[:host] + ':' + opts[:port].to_s() + opts[:uri] if msf_os.eql? "win" - print_info 'BeEF auto-connect with metasploit is currently not supported on MS Windows.' + 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+') From 17aa898099a2b1f53a20980b6f13e84aa50e54f6 Mon Sep 17 00:00:00 2001 From: bmantra Date: Wed, 6 Feb 2013 19:42:14 +0100 Subject: [PATCH 3/3] correct last commit, set auto_msfrpcd back to false --- extensions/metasploit/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/metasploit/config.yaml b/extensions/metasploit/config.yaml index 7303ddad2..6c52a2f56 100644 --- a/extensions/metasploit/config.yaml +++ b/extensions/metasploit/config.yaml @@ -25,7 +25,7 @@ beef: ssl_verify: true callback_host: "127.0.0.1" autopwn_url: "autopwn" - auto_msfrpcd: true + auto_msfrpcd: false auto_msfrpcd_timeout: 120 msf_path: [ {os: 'osx', path: '/opt/local/msf/'},