From d854751f82f5750c3e5f1043212f43e6d9de1ec4 Mon Sep 17 00:00:00 2001 From: sjanusz Date: Wed, 19 Jan 2022 17:18:47 +0000 Subject: [PATCH] Fix params not being passed to scripts --- lib/msf/ui/console/command_dispatcher/core.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index c7537fae03..668a22d82d 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -1351,6 +1351,7 @@ class Core response_timeout = 15 search_term = nil session_name = nil + has_script_arguments = false # any arguments that don't correspond to an option or option arg will # be put in here @@ -1362,6 +1363,8 @@ class Core else # Parse the command options @@sessions_opts.parse(args) do |opt, idx, val| + next if has_script_arguments + case opt when "-q", "--quiet" quiet = true @@ -1398,6 +1401,9 @@ class Core unless script method = 'script' script = val + # Assume any parameter after the script name is a flag/argument we want to pass to the script itself. + extra += args[(idx + 1)..-1] + has_script_arguments = true end # Upload and exec to the specific command session when "-u", "--upgrade"