Skip to content

Commit 596b2b0

Browse files
committed
Land rapid7#6173, improve advanced, info, and options
2 parents 2e88eb5 + a4c260f commit 596b2b0

File tree

2 files changed

+93
-8
lines changed

2 files changed

+93
-8
lines changed

features/commands/help.feature

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Feature: Help command
1212
Command Description
1313
------- -----------
1414
? Help menu
15+
advanced Displays advanced options for one or more modules
1516
back Move back from the current context
1617
banner Display an awesome metasploit banner
1718
cd Change the current working directory
@@ -24,13 +25,14 @@ Feature: Help command
2425
go_pro Launch Metasploit web GUI
2526
grep Grep the output of another command
2627
help Help menu
27-
info Displays information about one or more module
28+
info Displays information about one or more modules
2829
irb Drop into irb scripting mode
2930
jobs Displays and manages jobs
3031
kill Kill a job
3132
load Load a framework plugin
3233
loadpath Searches for and loads modules from a path
3334
makerc Save commands entered since start to a file
35+
options Displays global options or for one or more modules
3436
popm Pops the latest module off the stack and makes it active
3537
previous Sets the previously loaded module as the current module
3638
pushm Pushes the active or list of modules onto the module stack

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def commands
123123
"go_pro" => "Launch Metasploit web GUI",
124124
"grep" => "Grep the output of another command",
125125
"help" => "Help menu",
126-
"info" => "Displays information about one or more module",
126+
"advanced" => "Displays advanced options for one or more modules",
127+
"info" => "Displays information about one or more modules",
128+
"options" => "Displays global options or for one or more modules",
127129
"irb" => "Drop into irb scripting mode",
128130
"jobs" => "Displays and manages jobs",
129131
"rename_job" => "Rename a job",
@@ -712,6 +714,36 @@ def cmd_sleep(*args)
712714
Rex::ThreadSafe.sleep(args[0].to_f)
713715
end
714716

717+
def cmd_advanced_help
718+
print_line 'Usage: advanced [mod1 mod2 ...]'
719+
print_line
720+
print_line 'Queries the supplied module or modules for advanced options. If no module is given,'
721+
print_line 'show advanced options for the currently active module.'
722+
print_line
723+
end
724+
725+
def cmd_advanced(*args)
726+
if args.empty?
727+
if (active_module)
728+
show_advanced_options(active_module)
729+
return true
730+
else
731+
print_error('No module active')
732+
return false
733+
end
734+
end
735+
736+
args.each { |name|
737+
mod = framework.modules.create(name)
738+
739+
if (mod == nil)
740+
print_error("Invalid module: #{name}")
741+
else
742+
show_advanced_options(mod)
743+
end
744+
}
745+
end
746+
715747
def cmd_info_help
716748
print_line "Usage: info <module name> [mod2 mod3 ...]"
717749
print_line
@@ -748,17 +780,66 @@ def cmd_info(*args)
748780
}
749781
end
750782

783+
def cmd_options_help
784+
print_line 'Usage: options [mod1 mod2 ...]'
785+
print_line
786+
print_line 'Queries the supplied module or modules for options. If no module is given,'
787+
print_line 'show options for the currently active module.'
788+
print_line
789+
end
790+
791+
def cmd_options(*args)
792+
if args.empty?
793+
if (active_module)
794+
show_options(active_module)
795+
return true
796+
else
797+
show_global_options
798+
return true
799+
end
800+
end
801+
802+
args.each { |name|
803+
mod = framework.modules.create(name)
804+
805+
if (mod == nil)
806+
print_error("Invalid module: #{name}")
807+
else
808+
show_options(mod)
809+
end
810+
}
811+
end
812+
751813
#
752-
# Tab completion for the info command (same as use)
814+
# Tab completion for the advanced command (same as use)
753815
#
754-
# @param str [String] the string currently being typed before tab was hit
755-
# @param words [Array<String>] the previously completed words on the command line. words is always
756-
# at least 1 when tab completion has reached this stage since the command itself has been completed
816+
# @param str (see #cmd_use_tabs)
817+
# @param words (see #cmd_use_tabs)
818+
819+
def cmd_advanced_tabs(str, words)
820+
cmd_use_tabs(str, words)
821+
end
822+
823+
#
824+
# Tab completion for the advanced command (same as use)
825+
#
826+
# @param str (see #cmd_use_tabs)
827+
# @param words (see #cmd_use_tabs)
757828

758829
def cmd_info_tabs(str, words)
759830
cmd_use_tabs(str, words)
760831
end
761832

833+
#
834+
# Tab completion for the advanced command (same as use)
835+
#
836+
# @param str (see #cmd_use_tabs)
837+
# @param words (see #cmd_use_tabs)
838+
839+
def cmd_options_tabs(str, words)
840+
cmd_use_tabs(str, words)
841+
end
842+
762843
def cmd_irb_help
763844
print_line "Usage: irb"
764845
print_line
@@ -2204,7 +2285,7 @@ def cmd_setg_tabs(str, words)
22042285
end
22052286

22062287
def cmd_show_help
2207-
global_opts = %w{all encoders nops exploits payloads auxiliary plugins options}
2288+
global_opts = %w{all encoders nops exploits payloads auxiliary plugins info options}
22082289
print_status("Valid parameters for the \"show\" command are: #{global_opts.join(", ")}")
22092290

22102291
module_opts = %w{ missing advanced evasion targets actions }
@@ -2244,6 +2325,8 @@ def cmd_show(*args)
22442325
show_auxiliary
22452326
when 'post'
22462327
show_post
2328+
when 'info'
2329+
cmd_info(*args[1, args.length])
22472330
when 'options'
22482331
if (mod)
22492332
show_options(mod)
@@ -3465,7 +3548,7 @@ def show_actions(mod) # :nodoc:
34653548

34663549
def show_advanced_options(mod) # :nodoc:
34673550
mod_opt = Serializer::ReadableText.dump_advanced_options(mod, ' ')
3468-
print("\nModule advanced options:\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0)
3551+
print("\nModule advanced options (#{mod.fullname}):\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0)
34693552

34703553
# If it's an exploit and a payload is defined, create it and
34713554
# display the payload's options

0 commit comments

Comments
 (0)