Skip to content

Commit

Permalink
Use #compatible_payloads in #validate
Browse files Browse the repository at this point in the history
This updates the #validate methods to check if the selected payload is
in the modules list of compatible payloads instead of just checking the
platform.
  • Loading branch information
zeroSteiner committed Apr 18, 2024
1 parent 13a79ab commit ff295aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 2 additions & 3 deletions lib/msf/core/evasion_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def target_idx
# current evasion module. Assumes that target_idx is valid.
#
def compatible_payload?(payload)
evasion_platform = evasion.targets[target_idx].platform || evasion.platform
return ((payload.platform & evasion_platform).empty? == false)
!evasion.compatible_payloads.find { |refname, _| refname == payload.refname }.nil?
end

def validate
Expand All @@ -48,7 +47,7 @@ def validate
end

# Make sure the payload is compatible after all
if (compatible_payload?(payload) == false)
unless compatible_payload?(payload)
raise IncompatiblePayloadError.new(payload.refname), "#{payload.refname} is not a compatible payload.", caller
end

Expand Down
10 changes: 3 additions & 7 deletions lib/msf/core/exploit_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ def target_idx
# current exploit. Assumes that target_idx is valid.
#
def compatible_payload?(payload)
# Try to use the target's platform in preference of the exploit's
exp_platform = exploit.targets[target_idx].platform || exploit.platform

return ((payload.platform & exp_platform).empty? == false)
!exploit.compatible_payloads.find { |refname, _| refname == payload.refname }.nil?
end

##
Expand Down Expand Up @@ -83,9 +80,8 @@ def validate
end

# Make sure the payload is compatible after all
if (compatible_payload?(payload) == false)
raise IncompatiblePayloadError.new(payload.refname),
"#{payload.refname} is not a compatible payload.", caller
unless compatible_payload?(payload)
raise IncompatiblePayloadError.new(payload.refname), "#{payload.refname} is not a compatible payload.", caller
end

unless exploit.respond_to?(:allow_no_cleanup) && exploit.allow_no_cleanup
Expand Down

0 comments on commit ff295aa

Please sign in to comment.