Skip to content

Commit d121ca4

Browse files
committed
Merge pull request #29 from jvazquez-r7/review_5427
Use compatible_payloads instead of copy and paste
2 parents defda01 + af326a4 commit d121ca4

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

lib/msf/core/exploit.rb

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -707,36 +707,9 @@ def target_arch
707707
# @return [FalseClass] Payload is not compatible.
708708
#
709709
def is_payload_compatible?(payload_name)
710-
c_platform = (target and target.platform) ? target.platform : platform
711-
c_arch = (target and target.arch) ? target.arch : (arch == []) ? nil : arch
712-
c_arch ||= [ ARCH_X86 ]
713-
714-
framework.payloads.each_module(
715-
'Platform' => c_platform,
716-
'Arch' => c_arch ) { |name, mod|
717-
718-
# Skip over payloads that are too big
719-
if ((payload_space) and
720-
(framework.payloads.sizes[name]) and
721-
(framework.payloads.sizes[name] > payload_space))
722-
dlog("#{refname}: Skipping payload #{name} for being too large", 'core',
723-
LEV_1)
724-
next
725-
end
726-
727-
# Are we compatible in terms of conventions and connections and
728-
# what not?
729-
next if (compatible?(framework.payloads.instance(name)) == false)
730-
731-
# If the payload is privileged but the exploit does not give
732-
# privileged access, then fail it.
733-
next if (self.privileged == false and framework.payloads.instance(name).privileged == true)
734-
735-
# This one be compatible!
736-
return true if payload_name == name
737-
}
710+
payload_names = compatible_payloads.collect { |entry| entry[0] }
738711

739-
false
712+
payload_names.include?(payload_name)
740713
end
741714

742715
#

0 commit comments

Comments
 (0)