Land #11407, Add support for showing extra help in msfconsole
commit
fc45e7d1b1
|
@ -0,0 +1,37 @@
|
|||
Repeat
|
||||
======
|
||||
|
||||
The `repeat` command repeats one or more console commands for a fixed number of
|
||||
times, a certain length of time, or forever. The repeat command is most useful
|
||||
for repeating module runs like memory dumpers or scanners that have a random
|
||||
element to them.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### Flags
|
||||
|
||||
#### -t, --time SECONDS
|
||||
|
||||
Start the list of commands until the number of seconds has elapsed.
|
||||
|
||||
#### -n, --number TIMES
|
||||
|
||||
Start the list of commands a fixed number of times.
|
||||
|
||||
#### -h, --help
|
||||
|
||||
Display the help banner.
|
||||
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Run the heartbleed module every 10 seconds against a server for an hour:
|
||||
|
||||
msf5 > use auxiliary/scanner/ssl/openssl_heartbleed
|
||||
msf5 auxiliary(scanner/ssl/openssl_heartbleed) > set ACTION DUMP
|
||||
# Set other options...
|
||||
msf5 auxiliary(scanner/ssl/openssl_heartbleed) > repeat -t 3600 run; sleep 10
|
||||
|
|
@ -86,6 +86,14 @@ class CommandShell
|
|||
return true
|
||||
end
|
||||
|
||||
#
|
||||
# Return the subdir of the `documentation/` directory that should be used
|
||||
# to find usage documentation
|
||||
#
|
||||
def docs_dir
|
||||
File.join(super, 'shell_session')
|
||||
end
|
||||
|
||||
#
|
||||
# List of supported commands.
|
||||
#
|
||||
|
|
|
@ -74,6 +74,14 @@ module CommandDispatcher
|
|||
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_1)
|
||||
end
|
||||
|
||||
#
|
||||
# Return the subdir of the `documentation/` directory that should be used
|
||||
# to find usage documentation
|
||||
#
|
||||
def docs_dir
|
||||
File.join(super, 'msfconsole')
|
||||
end
|
||||
|
||||
#
|
||||
# Generate an array of job or session IDs from a given range String.
|
||||
# Always returns an Array.
|
||||
|
@ -105,6 +113,19 @@ module CommandDispatcher
|
|||
item_list.uniq.sort
|
||||
end
|
||||
|
||||
#
|
||||
# Remove lines with specific substring
|
||||
#
|
||||
# @param text [String] Block of text to search over
|
||||
# @param to_match [String] String that when found, causes the whole line to
|
||||
# be removed, including trailing "\n" if present
|
||||
# @return [String] Text sans lines containing to_match
|
||||
#
|
||||
def remove_lines(text, to_match)
|
||||
to_match = Regexp.escape(to_match)
|
||||
text.gsub(/^.*(#{to_match}).*(#{Regexp.escape $/})?/, '')
|
||||
end
|
||||
|
||||
#
|
||||
# The driver that this command dispatcher is associated with.
|
||||
#
|
||||
|
|
|
@ -1987,7 +1987,7 @@ class Core
|
|||
output_mods[:skip] = num
|
||||
end
|
||||
opts.on '-h', '--help', 'Help banner.' do
|
||||
return print(opts.help)
|
||||
return print(remove_lines(opts.help, '--generate-completions'))
|
||||
end
|
||||
|
||||
# Internal use
|
||||
|
@ -2102,7 +2102,7 @@ class Core
|
|||
end
|
||||
|
||||
opts.on '-h', '--help', 'Help banner.' do
|
||||
return print(opts.help)
|
||||
return print(remove_lines(opts.help, '--generate-completions'))
|
||||
end
|
||||
|
||||
# Internal use
|
||||
|
|
|
@ -58,6 +58,14 @@ module Console::CommandDispatcher
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Return the subdir of the `documentation/` directory that should be used
|
||||
# to find usage documentation
|
||||
#
|
||||
def docs_dir
|
||||
File.join(super, 'meterpreter')
|
||||
end
|
||||
|
||||
#
|
||||
# Returns true if the client has a framework object.
|
||||
#
|
||||
|
|
|
@ -174,10 +174,19 @@ module DispatcherShell
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if docs_dir && File.exist?(File.join(docs_dir, cmd + '.md'))
|
||||
print_line
|
||||
print(File.read(File.join(docs_dir, cmd + '.md')))
|
||||
end
|
||||
print_error("No help for #{cmd}, try -h") if cmd_found and not help_found
|
||||
print_error("No such command") if not cmd_found
|
||||
else
|
||||
print(shell.help_to_s)
|
||||
if docs_dir && File.exist?(File.join(docs_dir + '.md'))
|
||||
print_line
|
||||
print(File.read(File.join(docs_dir + '.md')))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -230,6 +239,17 @@ module DispatcherShell
|
|||
return "\n" + tbl.to_s + "\n"
|
||||
end
|
||||
|
||||
#
|
||||
# Return the subdir of the `documentation/` directory that should be used
|
||||
# to find usage documentation
|
||||
#
|
||||
# TODO: get this value from somewhere that doesn't invert a bunch of
|
||||
# dependencies
|
||||
#
|
||||
def docs_dir
|
||||
File.expand_path(File.join(__FILE__, '..', '..', '..', '..', '..', 'documentation', 'cli'))
|
||||
end
|
||||
|
||||
#
|
||||
# No tab completion items by default
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue