From 505eff4403deb32dffab15f445bc9dd5ebf68874 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Fri, 20 Apr 2018 18:11:49 -0500 Subject: [PATCH] Land #9898, Fix target NOP generator not passed to payload --- lib/msf/core/exploit.rb | 16 +++++++++++++++- lib/msf/core/module/target.rb | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index 0fe356cf5c..28c9fb57e9 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -551,7 +551,7 @@ class Exploit < Msf::Module reqs['MaxNops'] = payload_max_nops(explicit_target) reqs['MinNops'] = payload_min_nops(explicit_target) reqs['Encoder'] = datastore['ENCODER'] || payload_encoder(explicit_target) - reqs['Nop'] = datastore['NOP'] # TODO: Make like the others + reqs['Nop'] = datastore['NOP'] || payload_nop(explicit_target) reqs['EncoderType'] = payload_encoder_type(explicit_target) reqs['EncoderOptions'] = payload_encoder_options(explicit_target) reqs['ExtendedOptions'] = payload_extended_options(explicit_target) @@ -930,6 +930,20 @@ class Exploit < Msf::Module end end + # + # Returns the payload NOP generator that is associated with either the + # current target or the exploit in general. + # + def payload_nop(explicit_target = nil) + explicit_target ||= target + + if (explicit_target and explicit_target.payload_nop) + explicit_target.payload_nop + else + payload_info['Nop'] + end + end + # # Returns the payload encoder type that is associated with either the # current target or the exploit in general. diff --git a/lib/msf/core/module/target.rb b/lib/msf/core/module/target.rb index 931d14e0e5..2f1ebedd1c 100644 --- a/lib/msf/core/module/target.rb +++ b/lib/msf/core/module/target.rb @@ -241,6 +241,14 @@ class Msf::Module::Target opts['Payload'] ? opts['Payload']['Encoder'] : nil end + # + # The payload NOP generator or generators that can be used when generating the + # encoded payload (such as x86/opty2 and so on). + # + def payload_nop + opts['Payload'] ? opts['Payload']['Nop'] : 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).