Skip to content

Commit 25bdf7a

Browse files
committed
Land rapid7#5427, check payload compatability for set payload fix
2 parents e770826 + d121ca4 commit 25bdf7a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/msf/core/exploit.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,20 @@ def target_arch
698698
(target and target.arch) ? target.arch : (arch == []) ? nil : arch
699699
end
700700

701+
702+
#
703+
# Returns whether the requested payload is compatible with the module.
704+
#
705+
# @param [String] payload_name The payload name
706+
# @return [TrueClass] Payload is compatible.
707+
# @return [FalseClass] Payload is not compatible.
708+
#
709+
def is_payload_compatible?(payload_name)
710+
payload_names = compatible_payloads.collect { |entry| entry[0] }
711+
712+
payload_names.include?(payload_name)
713+
end
714+
701715
#
702716
# Returns a list of compatible payloads based on platform, architecture,
703717
# and size requirements.

lib/msf/ui/console/driver.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ def on_variable_set(glob, var, val)
571571

572572
if (framework and framework.payloads.valid?(val) == false)
573573
return false
574+
elsif active_module.type == 'exploit' && !active_module.is_payload_compatible?(val)
575+
return false
574576
elsif (active_module)
575577
active_module.datastore.clear_non_user_defined
576578
elsif (framework)

0 commit comments

Comments
 (0)