Skip to content

Commit b33ace2

Browse files
committed
Put is_payload_compatible? in exploit.rb
1 parent 583fccd commit b33ace2

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

lib/msf/core/exploit.rb

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

701+
def is_payload_compatible?(payload_name)
702+
c_platform = (target and target.platform) ? target.platform : platform
703+
c_arch = (target and target.arch) ? target.arch : (arch == []) ? nil : arch
704+
c_arch ||= [ ARCH_X86 ]
705+
706+
framework.payloads.each_module(
707+
'Platform' => c_platform,
708+
'Arch' => c_arch ) { |name, mod|
709+
710+
# Skip over payloads that are too big
711+
if ((payload_space) and
712+
(framework.payloads.sizes[name]) and
713+
(framework.payloads.sizes[name] > payload_space))
714+
dlog("#{refname}: Skipping payload #{name} for being too large", 'core',
715+
LEV_1)
716+
next
717+
end
718+
719+
# Are we compatible in terms of conventions and connections and
720+
# what not?
721+
next if (compatible?(framework.payloads.instance(name)) == false)
722+
723+
# If the payload is privileged but the exploit does not give
724+
# privileged access, then fail it.
725+
next if (self.privileged == false and framework.payloads.instance(name).privileged == true)
726+
727+
# This one be compatible!
728+
return true if payload_name == name
729+
}
730+
731+
false
732+
end
733+
701734
#
702735
# Returns a list of compatible payloads based on platform, architecture,
703736
# and size requirements.

lib/msf/ui/console/driver.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ 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)
574+
elsif active_module.type == 'exploit' && !active_module.is_payload_compatible?(val)
575575
return false
576576
elsif (active_module)
577577
active_module.datastore.clear_non_user_defined
@@ -591,15 +591,6 @@ def on_variable_set(glob, var, val)
591591
end
592592
end
593593

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-
603594
#
604595
# Called when a variable is unset. If this routine returns false it is an
605596
# indication that the variable should not be allowed to be unset.

0 commit comments

Comments
 (0)