Skip to content

Commit

Permalink
Land rapid7#18609, Fix empty download_exec payload
Browse files Browse the repository at this point in the history
Fix empty cmd/windows/powershell/download_exec payload

Closes rapid7#18607
  • Loading branch information
smcintyre-r7 committed Dec 13, 2023
2 parents a4ffd03 + a28e9fb commit 0f4644d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/msf/core/payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ def session

#
# Generates the payload and returns the raw buffer to the caller.
#
def generate(_opts = {})
internal_generate
# @param opts [Hash]
def generate(opts = {})
internal_generate(opts)
end

#
Expand Down Expand Up @@ -611,9 +611,10 @@ def on_session(session)
#
# @see PayloadSet#check_blob_cache
# @param asm [String] Assembly code to be assembled into a raw payload
# @param opts [Hash]
# @return [String] The final, assembled payload
# @raise ArgumentError if +asm+ is blank
def build(asm, off={})
def build(asm, off={}, opts = {})
if(asm.nil? or asm.empty?)
raise ArgumentError, "Assembly must not be empty"
end
Expand Down Expand Up @@ -644,7 +645,7 @@ def build(asm, off={})
end

# Assemble the payload from the assembly
a = self.arch
a = opts[:arch] || self.arch
if a.kind_of? Array
a = self.arch.first
end
Expand Down Expand Up @@ -677,11 +678,11 @@ def build(asm, off={})
#
# Generate the payload using our local payload blob and offsets
#
def internal_generate
def internal_generate(opts = {})
# Build the payload, either by using the raw payload blob defined in the
# module or by actually assembling it
if assembly and !assembly.empty?
raw = build(assembly, offsets)
raw = build(assembly, offsets, opts)
else
raw = payload.dup
end
Expand Down

0 comments on commit 0f4644d

Please sign in to comment.