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.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/parsed_options/console.rb
Views: 11784
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.real_readline = false
20
options.console.resources = []
21
options.console.subcommand = :run
22
}
23
end
24
25
@options
26
end
27
28
private
29
30
# Parses msfconsole arguments into {#options}.
31
#
32
# @return [OptionParser]
33
def option_parser
34
unless @option_parser
35
super.tap { |option_parser|
36
option_parser.banner = "Usage: #{option_parser.program_name} [options]"
37
38
option_parser.separator 'Console options:'
39
40
option_parser.on('-a', '--ask', "Ask before exiting Metasploit or accept 'exit -y'") do
41
options.console.confirm_exit = true
42
end
43
44
option_parser.on('-H', '--history-file FILE', 'Save command history to the specified file') do |file|
45
options.console.histfile = file
46
end
47
48
option_parser.on('-l', '--logger STRING', "Specify a logger to use (#{Rex::Logging::LogSinkFactory.available_sinks.join(', ')})") do |logger|
49
options.console.logger = logger
50
end
51
52
option_parser.on('--[no-]readline') do |readline|
53
options.console.readline = readline
54
end
55
56
option_parser.on('-L', '--real-readline', 'Use the system Readline library instead of RbReadline') do
57
options.console.real_readline = true
58
end
59
60
option_parser.on('-o', '--output FILE', 'Output to the specified file') do |file|
61
options.console.local_output = file
62
end
63
64
option_parser.on('-p', '--plugin PLUGIN', 'Load a plugin on startup') do |plugin|
65
options.console.plugins << plugin
66
end
67
68
option_parser.on('-q', '--quiet', 'Do not print the banner on startup') do
69
options.console.quiet = true
70
end
71
72
option_parser.on('-r', '--resource FILE', 'Execute the specified resource file (- for stdin)') do |file|
73
options.console.resources << file
74
end
75
76
option_parser.on(
77
'-x',
78
'--execute-command COMMAND',
79
'Execute the specified console commands (use ; for multiples)'
80
) do |commands|
81
options.console.commands += commands.split(/\s*;\s*/)
82
end
83
}
84
end
85
86
@option_parser
87
end
88
end
89
90