CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/parsed_options/console.rb
Views: 15919
1
# Parsed options for {Metasploit::Framework::Command::Console}
2
class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::ParsedOptions::Base
3
# Options parsed from msfconsole command-line.
4
#
5
# @return [ActiveSupport::OrderedOptions]
6
def options
7
unless @options
8
super.tap { |options|
9
options.console = ActiveSupport::OrderedOptions.new
10
11
options.console.commands = []
12
options.console.confirm_exit = false
13
options.console.histfile = nil
14
options.console.logger = nil
15
options.console.local_output = nil
16
options.console.plugins = []
17
options.console.quiet = false
18
options.console.readline = true
19
options.console.resources = []
20
options.console.subcommand = :run
21
}
22
end
23
24
@options
25
end
26
27
private
28
29
# Parses msfconsole arguments into {#options}.
30
#
31
# @return [OptionParser]
32
def option_parser
33
unless @option_parser
34
super.tap { |option_parser|
35
option_parser.banner = "Usage: #{option_parser.program_name} [options]"
36
37
option_parser.separator 'Console options:'
38
39
option_parser.on('-a', '--ask', "Ask before exiting Metasploit or accept 'exit -y'") do
40
options.console.confirm_exit = true
41
end
42
43
option_parser.on('-H', '--history-file FILE', 'Save command history to the specified file') do |file|
44
options.console.histfile = file
45
end
46
47
option_parser.on('-l', '--logger STRING', "Specify a logger to use (#{Rex::Logging::LogSinkFactory.available_sinks.join(', ')})") do |logger|
48
options.console.logger = logger
49
end
50
51
option_parser.on('--[no-]readline') do |readline|
52
options.console.readline = readline
53
end
54
55
option_parser.on('-L', '--real-readline', 'Use the system Readline library instead of RbReadline') do
56
message = "The RealReadline option has been marked as deprecated, and is currently a noop.\n"
57
message << "If you require this functionality, please use the following link to tell us:\n"
58
message << ' https://github.com/rapid7/metasploit-framework/issues/19399'
59
warn message
60
end
61
62
option_parser.on('-o', '--output FILE', 'Output to the specified file') do |file|
63
options.console.local_output = file
64
end
65
66
option_parser.on('-p', '--plugin PLUGIN', 'Load a plugin on startup') do |plugin|
67
options.console.plugins << plugin
68
end
69
70
option_parser.on('-q', '--quiet', 'Do not print the banner on startup') do
71
options.console.quiet = true
72
end
73
74
option_parser.on('-r', '--resource FILE', 'Execute the specified resource file (- for stdin)') do |file|
75
options.console.resources << file
76
end
77
78
option_parser.on(
79
'-x',
80
'--execute-command COMMAND',
81
'Execute the specified console commands (use ; for multiples)'
82
) do |commands|
83
options.console.commands += commands.split(/\s*;\s*/)
84
end
85
}
86
end
87
88
@option_parser
89
end
90
end
91
92