@@ -698,6 +698,39 @@ def target_arch
698
698
( target and target . arch ) ? target . arch : ( arch == [ ] ) ? nil : arch
699
699
end
700
700
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
+
701
734
#
702
735
# Returns a list of compatible payloads based on platform, architecture,
703
736
# and size requirements.
0 commit comments