diff --git a/lib/msf/base/simple/exploit.rb b/lib/msf/base/simple/exploit.rb index b9e0833d28..1536ef2985 100644 --- a/lib/msf/base/simple/exploit.rb +++ b/lib/msf/base/simple/exploit.rb @@ -109,13 +109,9 @@ module Exploit # Verify the payload options driver.payload.options.validate(driver.payload.datastore) - # If we still have no target index, try to use the datastore's index - target_idx = opts['Target'] || exploit.default_target - - # Convert it to an integer if it's valid - if (target_idx) - target_idx = target_idx.to_i - end + # Set the target and then work some magic to derive index + exploit.datastore['TARGET'] = opts['Target'] if opts['Target'] + target_idx = exploit.target_index if (target_idx == nil or target_idx < 0) raise MissingTargetError, diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index 1387c253c2..82110ce94f 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -14,15 +14,15 @@ class Exploit include Msf::Ui::Console::ModuleCommandDispatcher @@exploit_opts = Rex::Parser::Arguments.new( - "-e" => [ true, "The payload encoder to use. If none is specified, ENCODER is used." ], - "-f" => [ false, "Force the exploit to run regardless of the value of MinimumRank." ], - "-h" => [ false, "Help banner." ], - "-j" => [ false, "Run in the context of a job." ], - "-n" => [ true, "The NOP generator to use. If none is specified, NOP is used." ], - "-o" => [ true, "A comma separated list of options in VAR=VAL format." ], - "-p" => [ true, "The payload to use. If none is specified, PAYLOAD is used." ], - "-t" => [ true, "The target index to use. If none is specified, TARGET is used." ], - "-z" => [ false, "Do not interact with the session after successful exploitation." ]) + "-e" => [ true, "The payload encoder to use. If none is specified, ENCODER is used." ], + "-f" => [ false, "Force the exploit to run regardless of the value of MinimumRank." ], + "-h" => [ false, "Help banner." ], + "-j" => [ false, "Run in the context of a job." ], + "-n" => [ true, "The NOP generator to use. If none is specified, NOP is used." ], + "-o" => [ true, "A comma separated list of options in VAR=VAL format." ], + "-p" => [ true, "The payload to use. If none is specified, PAYLOAD is used." ], + "-t" => [ true, "The target index or name to use. If none is specified, TARGET is used." ], + "-z" => [ false, "Do not interact with the session after successful exploitation." ]) # # Returns the hash of exploit module specific commands. @@ -79,7 +79,7 @@ class Exploit when '-p' payload = val when '-t' - target = val.to_i + target = val when '-z' bg = true when '-h'