Skip to content

Commit 583fccd

Browse files
committed
Resolve rapid7#5404, Check payload compatibility when using set payload
Resolve rapid7#5404. This patch will check payload compatibility when you are using set payload in msfconsole.
1 parent 2ae9e39 commit 583fccd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/msf/ui/console/driver.rb

Lines changed: 11 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' && !is_payload_compatible?(active_module, val)
575+
return false
574576
elsif (active_module)
575577
active_module.datastore.clear_non_user_defined
576578
elsif (framework)
@@ -589,6 +591,15 @@ def on_variable_set(glob, var, val)
589591
end
590592
end
591593

594+
595+
def is_payload_compatible?(m, payload_name)
596+
m.compatible_payloads.each do |k|
597+
return true if k[0] == payload_name
598+
end
599+
600+
false
601+
end
602+
592603
#
593604
# Called when a variable is unset. If this routine returns false it is an
594605
# indication that the variable should not be allowed to be unset.

0 commit comments

Comments
 (0)