auto launch metasploit initial commit
This commit is contained in:
@@ -32,5 +32,14 @@ beef:
|
||||
uri: '/api'
|
||||
ssl: false
|
||||
ssl_version: 'SSLv3'
|
||||
ssl_verify: true
|
||||
callback_host: "127.0.0.1"
|
||||
autopwn_url: "autopwn"
|
||||
auto_msfrpcd: true
|
||||
auto_msfrpcd_timeout: 120
|
||||
msf_path: [
|
||||
{os: 'osx', path: '/tmp/'},
|
||||
{os: 'bt5', path: '/opt/metasploit/'},
|
||||
{os: 'win', path: 'c:\metasploit\msf3\'},
|
||||
{os: 'custom', path: ''}
|
||||
]
|
||||
|
||||
@@ -43,6 +43,57 @@ module Metasploit
|
||||
:ssl_version => @config['ssl_version'] ,
|
||||
:context => {}
|
||||
}
|
||||
#auto start msfrpcd
|
||||
if (@config['auto_msfrpcd'] || false)
|
||||
launch_msf = ''
|
||||
@config['msf_path'].each do |path|
|
||||
if File.exist?(path['path'] + 'msfrpcd')
|
||||
launch_msf = path['path'] + 'msfrpcd'
|
||||
print_info 'Found msfrpcd: ' + launch_msf
|
||||
end
|
||||
end
|
||||
if (launch_msf.length > 0)
|
||||
msf_url = ''
|
||||
argssl = ''
|
||||
if not opts[:ssl]
|
||||
argssl = '-S'
|
||||
msf_url = 'http://'
|
||||
else
|
||||
msf_url = 'https://'
|
||||
end
|
||||
|
||||
msf_url += opts[:host] + ':' + opts[:port].to_s() + opts[:uri]
|
||||
|
||||
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
|
||||
|
||||
#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
|
||||
end
|
||||
else
|
||||
print_error 'Please add a custom path for msfrpcd to the config-file.'
|
||||
end
|
||||
end
|
||||
super(opts)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user