Land #9892, Fix target encoder not being passed to payload

4.x
Brent Cook 2018-04-20 14:41:44 -05:00 committed by Metasploit
parent 6cbd7ba895
commit abfcdc3fa7
No known key found for this signature in database
GPG Key ID: CDFB5FA52007B954
2 changed files with 25 additions and 3 deletions

View File

@ -550,8 +550,8 @@ class Exploit < Msf::Module
reqs['AppendEncoder'] = payload_append_encoder(explicit_target)
reqs['MaxNops'] = payload_max_nops(explicit_target)
reqs['MinNops'] = payload_min_nops(explicit_target)
reqs['Encoder'] = datastore['ENCODER']
reqs['Nop'] = datastore['NOP']
reqs['Encoder'] = datastore['ENCODER'] || payload_encoder(explicit_target)
reqs['Nop'] = datastore['NOP'] # TODO: Make like the others
reqs['EncoderType'] = payload_encoder_type(explicit_target)
reqs['EncoderOptions'] = payload_encoder_options(explicit_target)
reqs['ExtendedOptions'] = payload_extended_options(explicit_target)
@ -916,9 +916,23 @@ class Exploit < Msf::Module
end
end
#
# Returns the payload encoder that is associated with either the
# current target or the exploit in general.
#
def payload_encoder(explicit_target = nil)
explicit_target ||= target
if (explicit_target and explicit_target.payload_encoder)
explicit_target.payload_encoder
else
payload_info['Encoder']
end
end
#
# Returns the payload encoder type that is associated with either the
# current target of the exploit in general.
# current target or the exploit in general.
#
def payload_encoder_type(explicit_target = nil)
explicit_target ||= target

View File

@ -233,6 +233,14 @@ class Msf::Module::Target
opts['Payload'] ? opts['Payload']['Space'] : nil
end
#
# The payload encoder or encoders that can be used when generating the
# encoded payload (such as x86/shikata_ga_nai and so on).
#
def payload_encoder
opts['Payload'] ? opts['Payload']['Encoder'] : nil
end
#
# The payload encoder type or types that can be used when generating the
# encoded payload (such as alphanum, unicode, xor, and so on).